MCPcopy Index your code
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
151
152def get_git_commit_hash(repo_path: Path) -> str:
153 """
154 Get current git commit hash.
155
156 Searches parent directories to support monorepo subdirectories.
157
158 Args:
159 repo_path: Path inside a git repository
160
161 Returns:
162 Commit hash or empty string if not in a git repo
163 """
164 repo = _get_git_repo(repo_path)
165 if repo is None:
166 return ""
167
168 try:
169 return repo.head.commit.hexsha
170 except Exception:
171 return ""
172
173
174def get_git_branch(repo_path: Path) -> str:

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