Allow forcing the branch name on the automatic quality control script
Marco Ricci

Marco Ricci commited on 2025-02-11 13:57:22
Zeige 1 geänderte Dateien mit 4 Einfügungen und 1 Löschungen.


Allow forcing the branch name via the `GIT_CURRENT_BRANCH` environment
variable.  This is useful when the script doubles as a pre-commit hook,
and when we want to run the full set of checks normally reserved for
'master' only.
... ...
@@ -28,12 +28,15 @@ import sys
28 28
 envs = ['3.9', '3.11', '3.13', 'pypy3.10']
29 29
 opts = ['-py', ','.join(envs)]
30 30
 
31
-current_branch = subprocess.run(
31
+current_branch = (
32
+    os.getenv('GIT_CURRENT_BRANCH')
33
+    or subprocess.run(
32 34
         ['git', 'branch', '--show-current'],
33 35
         capture_output=True,
34 36
         text=True,
35 37
         check=False,
36 38
     ).stdout.strip()
39
+)
37 40
 # We use rev-parse to check for Stacked Git's metadata tracking branch,
38 41
 # instead of checking `stg top` or similar, because we also want the
39 42
 # first `stg new` or `stg import` to correctly detect that we are
40 43