Return the current HEAD SHA, or None if not a git repo / no commits.
(cwd)
| 30 | |
| 31 | |
| 32 | def _git_rev_parse_head(cwd): |
| 33 | """Return the current HEAD SHA, or None if not a git repo / no commits.""" |
| 34 | try: |
| 35 | result = subprocess.run( |
| 36 | [*GIT_CMD, "rev-parse", "HEAD"], |
| 37 | cwd=cwd, capture_output=True, text=True, timeout=5 |
| 38 | ) |
| 39 | if result.returncode == 0 and result.stdout.strip(): |
| 40 | return result.stdout.strip() |
| 41 | return None |
| 42 | except (subprocess.TimeoutExpired, FileNotFoundError, OSError): |
| 43 | return None |
| 44 | |
| 45 | |
| 46 |
no outgoing calls
no test coverage detected