MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeWiki / get_git_commit_hash

Function get_git_commit_hash

codewiki/cli/utils/repo_validator.py:152–171  ·  view source on GitHub ↗

Get current git commit hash. Searches parent directories to support monorepo subdirectories. Args: repo_path: Path inside a git repository Returns: Commit hash or empty string if not in a git repo

(repo_path: Path)

Source from the content-addressed store, hash-verified

150def get_git_commit_hash(repo_path: Path) -> str:
151 """
152 Get current git commit hash.
153
154 Searches parent directories to support monorepo subdirectories.
155
156 Args:
157 repo_path: Path inside a git repository
158
159 Returns:
160 Commit hash or empty string if not in a git repo
161 """
162 repo = _get_git_repo(repo_path)
163 if repo is None:
164 return ""
165
166 try:
167 return repo.head.commit.hexsha
168 except Exception: # noqa: BLE001 — commit info is optional metadata
169 return ""
170
171
172def get_git_branch(repo_path: Path) -> str:
173 """
174 Get current git branch name.

Callers 4

generate_commandFunction · 0.90
_legacy_generate_docsFunction · 0.90
handle_analyze_repoFunction · 0.90

Calls 1

_get_git_repoFunction · 0.85

Tested by

no test coverage detected