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

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

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