MCPcopy
hub / github.com/anthropics/claude-code / _git_toplevel

Function _git_toplevel

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

Absolute repo root for `cwd`, or None if not in a work tree.

(cwd)

Source from the content-addressed store, hash-verified

142
143
144def _git_toplevel(cwd):
145 """Absolute repo root for `cwd`, or None if not in a work tree."""
146 try:
147 r = subprocess.run(
148 [*GIT_CMD, "rev-parse", "--show-toplevel"],
149 cwd=cwd, capture_output=True, text=True, timeout=5,
150 )
151 return r.stdout.strip() if r.returncode == 0 and r.stdout.strip() else None
152 except (subprocess.TimeoutExpired, FileNotFoundError, OSError):
153 return None
154
155
156def _git_dir(repo_root):

Callers 5

_list_untrackedFunction · 0.90
compute_v2_review_setFunction · 0.90
_claim_bash_hook_onceFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected