MCPcopy Index your code
hub / github.com/FSoft-AI4Code/CodeWiki / get_git_branch

Function get_git_branch

codewiki/cli/utils/repo_validator.py:174–193  ·  view source on GitHub ↗

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

(repo_path: Path)

Source from the content-addressed store, hash-verified

172
173
174def get_git_branch(repo_path: Path) -> str:
175 """
176 Get current git branch name.
177
178 Searches parent directories to support monorepo subdirectories.
179
180 Args:
181 repo_path: Path inside a git repository
182
183 Returns:
184 Branch name or empty string if not in a git repo
185 """
186 repo = _get_git_repo(repo_path)
187 if repo is None:
188 return ""
189
190 try:
191 return repo.active_branch.name
192 except Exception:
193 return ""
194
195
196def count_code_files(repo_path: Path) -> int:

Callers 1

generate_commandFunction · 0.90

Calls 1

_get_git_repoFunction · 0.85

Tested by

no test coverage detected