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)
| 172 | |
| 173 | |
| 174 | def 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 | |
| 196 | def count_code_files(repo_path: Path) -> int: |
no test coverage detected