mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 15:36:21 -04:00
* fix(is-git-repo): recognize bare repositories is_git_repo() used `git rev-parse --show-toplevel` to detect whether the current directory is inside a git repository. --show-toplevel fails for bare repositories since they have no working tree, so every command that relies on this shared helper (e.g. `git browse`) reports "Not a git repo!" when run from inside a bare repo, even though it plainly is one. Switch to `git rev-parse --git-dir`, which succeeds for both normal and bare repositories and keeps the existing "not a repo" behavior for non-repo directories. Fixes #1238, reported and LGTM'd by maintainers there with this exact fix; no PR had been opened for it yet. Adds tests/is-git-repo.bats covering: a normal repo, a bare repo, and a plain (non-repo) directory. * Fix ruff lint failures in scripts/checkstyle.py This PR's new Ruff CI job surfaced pre-existing style issues (unsorted imports, deprecated typing.List/Dict, nested ifs, bare exit()) in checkstyle.py. Cleaned these up so the newly added lint job passes. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com> |
||
|---|---|---|
| .. | ||
| bin | ||
| git-abort.bats | ||
| git-alias.bats | ||
| git-archive-file.bats | ||
| git-authors.bats | ||
| git-browse-ci.bats | ||
| git-browse.bats | ||
| git-continue.bats | ||
| git-scp.bats | ||
| is-git-repo.bats | ||
| README.md | ||
| test_util.sh | ||
Testing
Tests are written in Bats so coverage can be calculated for shell commands.
Bats Testing
We require a somewhat recent version of Bats. Version v1.8.1 is tested in CI. Once it is installed, the tests can be executed like so:
bats ./tests
We highly recommend adding Bats tests for new features and fixes.
Code Coverage
Coverage can be calculated with bashcov like so:
bashcov -- bats ./tests
By default, the report will be generated in ./coverage/index.html.