]> git.madduck.net Git - etc/vim.git/commitdiff

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Use GH action version when version argument not specified (#3543)
authorJakub Kuczys <me@jacken.men>
Tue, 28 Mar 2023 01:40:27 +0000 (03:40 +0200)
committerGitHub <noreply@github.com>
Tue, 28 Mar 2023 01:40:27 +0000 (18:40 -0700)
.git_archival.txt [new file with mode: 0644]
.gitattributes [new file with mode: 0644]
CHANGES.md
action/main.py

diff --git a/.git_archival.txt b/.git_archival.txt
new file mode 100644 (file)
index 0000000..8fb235d
--- /dev/null
@@ -0,0 +1,4 @@
+node: $Format:%H$
+node-date: $Format:%cI$
+describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$
+ref-names: $Format:%D$
diff --git a/.gitattributes b/.gitattributes
new file mode 100644 (file)
index 0000000..00a7b00
--- /dev/null
@@ -0,0 +1 @@
+.git_archival.txt  export-subst
index a429e32c8bd65ad53f5c5dc59e993652127c6c63..47c04a7bc769a5ffb180b8eb2f51e01a003d2592 100644 (file)
@@ -61,6 +61,9 @@
 
 <!-- For example, Docker, GitHub Actions, pre-commit, editors -->
 
 
 <!-- For example, Docker, GitHub Actions, pre-commit, editors -->
 
+- Update GitHub Action to use the version of Black equivalent to action's version if
+  version input is not specified (#3543)
+
 ### Documentation
 
 <!-- Major changes to documentation and policies. Small docs changes
 ### Documentation
 
 <!-- Major changes to documentation and policies. Small docs changes
index ff9d4112aed7f19f14930284ef38ee6134a8bc05..23c3a652194f20049eec3183f93067443b594507 100644 (file)
@@ -22,12 +22,34 @@ if JUPYTER:
     extra_deps = "[colorama,jupyter]"
 else:
     extra_deps = "[colorama]"
     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",
 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)
 )
 if pip_proc.returncode:
     print(pip_proc.stdout)