prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  GitHub Action: Use action version as default Black version, instead of latest
  > I'm alright with making the default Black version tied to the action version being used. For context `version` was introduced because the action didn't exist for a long time so tying black version to action version wouldn't work for version 19.10b0 for example. In hidesight, having the default being the action version keeping the `version` configuration option around as an escape hatch is the better solution. This will involve some complexity since commit SHAs aren't supported by the version code (but are by GHA) but there might be some pre-existing logic in scripts/diff_shades_gha_helper.py we could reuse.
  
  _Originally posted by @ichard26 in https://github.com/psf/black/issues/1140#issuecomment-1026379455_
        
  
  </issue>
  <code>
  [start of action/main.py]
  1 import os
  2 import shlex
  3 import sys
  4 from pathlib import Path
  5 from subprocess import PIPE, STDOUT, run
  6 
  7 ACTION_PATH = Path(os.environ["GITHUB_ACTION_PATH"])
  8 ENV_PATH = ACTION_PATH / ".black-env"
  9 ENV_BIN = ENV_PATH / ("Scripts" if sys.platform == "win32" else "bin")
  10 OPTIONS = os.getenv("INPUT_OPTIONS", default="")
  11 SRC = os.getenv("INPUT_SRC", default="")
  12 JUPYTER = os.getenv("INPUT_JUPYTER") == "true"
  13 BLACK_ARGS = os.getenv("INPUT_BLACK_ARGS", default="")
  14 VERSION = os.getenv("INPUT_VERSION", default="")
  15 
  16 run([sys.executable, "-m", "venv", str(ENV_PATH)], check=True)
  17 
  18 version_specifier = VERSION
  19 if VERSION and VERSION[0] in "0123456789":
  20     version_specifier = f"=={VERSION}"
  21 if JUPYTER:
  22     extra_deps = "[colorama,jupyter]"
  23 else:
  24     extra_deps = "[colorama]"
  25 req = f"black{extra_deps}{version_specifier}"
  26 pip_proc = run(
  27     [str(ENV_BIN / "python"), "-m", "pip", "install", req],
  28     stdout=PIPE,
  29     stderr=STDOUT,
  30     encoding="utf-8",
  31 )
  32 if pip_proc.returncode:
  33     print(pip_proc.stdout)
  34     print("::error::Failed to install Black.", flush=True)
  35     sys.exit(pip_proc.returncode)
  36 
  37 
  38 base_cmd = [str(ENV_BIN / "black")]
  39 if BLACK_ARGS:
  40     # TODO: remove after a while since this is deprecated in favour of SRC + OPTIONS.
  41     proc = run([*base_cmd, *shlex.split(BLACK_ARGS)])
  42 else:
  43     proc = run([*base_cmd, *shlex.split(OPTIONS), *shlex.split(SRC)])
  44 
  45 sys.exit(proc.returncode)
  46
  [end of action/main.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/action/main.py b/action/main.py
  --- a/action/main.py
  +++ b/action/main.py
  @@ -22,12 +22,34 @@
       extra_deps = "[colorama,jupyter]"
   else:
       extra_deps = "[colorama]"
  -req = f"black{extra_deps}{version_specifier}"
  +if version_specifier:
  +    req = f"black{extra_deps}{version_specifier}"
  +else:
  +    describe_name = ""
  +    with open(ACTION_PATH / ".git_archival.txt", encoding="utf-8") as fp:
  +        for line in fp:
  +            if line.startswith("describe-name: "):
  +                describe_name = line[len("describe-name: ") :].rstrip()
  +                break
  +    if not describe_name:
  +        print("::error::Failed to detect action version.", flush=True)
  +        sys.exit(1)
  +    # expected format is one of:
  +    # - 23.1.0
  +    # - 23.1.0-51-g448bba7
  +    if describe_name.count("-") < 2:
  +        # the action's commit matches a tag exactly, install exact version from PyPI
  +        req = f"black{extra_deps}=={describe_name}"
  +    else:
  +        # the action's commit does not match any tag, install from the local git repo
  +        req = f".{extra_deps}"
  +print(f"Installing {req}...", flush=True)
   pip_proc = run(
       [str(ENV_BIN / "python"), "-m", "pip", "install", req],
       stdout=PIPE,
       stderr=STDOUT,
       encoding="utf-8",
  +    cwd=ACTION_PATH,
   )
   if pip_proc.returncode:
       print(pip_proc.stdout)
  
verification_info: {"golden_diff": "diff --git a/action/main.py b/action/main.py\n--- a/action/main.py\n+++ b/action/main.py\n@@ -22,12 +22,34 @@\n     extra_deps = \"[colorama,jupyter]\"\n else:\n     extra_deps = \"[colorama]\"\n-req = f\"black{extra_deps}{version_specifier}\"\n+if version_specifier:\n+    req = f\"black{extra_deps}{version_specifier}\"\n+else:\n+    describe_name = \"\"\n+    with open(ACTION_PATH / \".git_archival.txt\", encoding=\"utf-8\") as fp:\n+        for line in fp:\n+            if line.startswith(\"describe-name: \"):\n+                describe_name = line[len(\"describe-name: \") :].rstrip()\n+                break\n+    if not describe_name:\n+        print(\"::error::Failed to detect action version.\", flush=True)\n+        sys.exit(1)\n+    # expected format is one of:\n+    # - 23.1.0\n+    # - 23.1.0-51-g448bba7\n+    if describe_name.count(\"-\") < 2:\n+        # the action's commit matches a tag exactly, install exact version from PyPI\n+        req = f\"black{extra_deps}=={describe_name}\"\n+    else:\n+        # the action's commit does not match any tag, install from the local git repo\n+        req = f\".{extra_deps}\"\n+print(f\"Installing {req}...\", flush=True)\n pip_proc = run(\n     [str(ENV_BIN / \"python\"), \"-m\", \"pip\", \"install\", req],\n     stdout=PIPE,\n     stderr=STDOUT,\n     encoding=\"utf-8\",\n+    cwd=ACTION_PATH,\n )\n if pip_proc.returncode:\n     print(pip_proc.stdout)\n", "issue": "GitHub Action: Use action version as default Black version, instead of latest\n> I'm alright with making the default Black version tied to the action version being used. For context `version` was introduced because the action didn't exist for a long time so tying black version to action version wouldn't work for version 19.10b0 for example. In hidesight, having the default being the action version keeping the `version` configuration option around as an escape hatch is the better solution. This will involve some complexity since commit SHAs aren't supported by the version code (but are by GHA) but there might be some pre-existing logic in scripts/diff_shades_gha_helper.py we could reuse.\r\n\r\n_Originally posted by @ichard26 in https://github.com/psf/black/issues/1140#issuecomment-1026379455_\r\n      \n", "before_files": [{"content": "import os\nimport shlex\nimport sys\nfrom pathlib import Path\nfrom subprocess import PIPE, STDOUT, run\n\nACTION_PATH = Path(os.environ[\"GITHUB_ACTION_PATH\"])\nENV_PATH = ACTION_PATH / \".black-env\"\nENV_BIN = ENV_PATH / (\"Scripts\" if sys.platform == \"win32\" else \"bin\")\nOPTIONS = os.getenv(\"INPUT_OPTIONS\", default=\"\")\nSRC = os.getenv(\"INPUT_SRC\", default=\"\")\nJUPYTER = os.getenv(\"INPUT_JUPYTER\") == \"true\"\nBLACK_ARGS = os.getenv(\"INPUT_BLACK_ARGS\", default=\"\")\nVERSION = os.getenv(\"INPUT_VERSION\", default=\"\")\n\nrun([sys.executable, \"-m\", \"venv\", str(ENV_PATH)], check=True)\n\nversion_specifier = VERSION\nif VERSION and VERSION[0] in \"0123456789\":\n    version_specifier = f\"=={VERSION}\"\nif JUPYTER:\n    extra_deps = \"[colorama,jupyter]\"\nelse:\n    extra_deps = \"[colorama]\"\nreq = f\"black{extra_deps}{version_specifier}\"\npip_proc = run(\n    [str(ENV_BIN / \"python\"), \"-m\", \"pip\", \"install\", req],\n    stdout=PIPE,\n    stderr=STDOUT,\n    encoding=\"utf-8\",\n)\nif pip_proc.returncode:\n    print(pip_proc.stdout)\n    print(\"::error::Failed to install Black.\", flush=True)\n    sys.exit(pip_proc.returncode)\n\n\nbase_cmd = [str(ENV_BIN / \"black\")]\nif BLACK_ARGS:\n    # TODO: remove after a while since this is deprecated in favour of SRC + OPTIONS.\n    proc = run([*base_cmd, *shlex.split(BLACK_ARGS)])\nelse:\n    proc = run([*base_cmd, *shlex.split(OPTIONS), *shlex.split(SRC)])\n\nsys.exit(proc.returncode)\n", "path": "action/main.py"}]}