import re


def get_image_tag(script_file):
  """Returns the image tag based on the script file produced by the `container_push`
  rule (`rules_docker` rules)."""
  with open(script_file, "r") as script:
    match = re.search(r"--name=([^ ]+)", script.read())
  if not match:
    raise Exception(
        "cannot get image name: the version of rules_docker is probably not supported"
    )
  return match.group(1)