Get a `(branch_name, commit_id)` tuple from the current direcory.
()
| 189 | |
| 190 | |
| 191 | def _get_git_branch_and_commit() -> Tuple[str, str]: |
| 192 | """ Get a `(branch_name, commit_id)` tuple from the current direcory. """ |
| 193 | branch_name = "NO_BRANCH" |
| 194 | commit = "NO_COMMIT" |
| 195 | try: |
| 196 | repo = Repo(__file__, search_parent_directories=True) |
| 197 | try: |
| 198 | branch_name = str(repo.active_branch) |
| 199 | except TypeError: |
| 200 | pass # Keep current/default branch_name |
| 201 | commit = str(repo.commit()) |
| 202 | if repo.is_dirty(): |
| 203 | commit += " + uncomitted changes" |
| 204 | except InvalidGitRepositoryError: |
| 205 | pass # Keep current/default branch_name and commit |
| 206 | return branch_name, commit |
no outgoing calls
no test coverage detected
searching dependent graphs…