MCPcopy Create free account
hub / github.com/anthropics/claude-code / _git_rev_parse_head

Function _git_rev_parse_head

plugins/security-guidance/hooks/gitutil.py:32–43  ·  view source on GitHub ↗

Return the current HEAD SHA, or None if not a git repo / no commits.

(cwd)

Source from the content-addressed store, hash-verified

30
31
32def _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

Callers 2

compute_v2_review_setFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected