summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Hunter <m@lfurio.us>2026-02-21 17:35:55 -0500
committerMatt Hunter <m@lfurio.us>2026-02-22 18:22:05 -0500
commit2477bb20257689d4d680701934cdb659c8f6fb37 (patch)
tree43098671ed2777f546444c28a30bff41983b1715
parent0b96dee27bff6276f0f435c52327eecbbd0aa4e5 (diff)
downloadgit-sonar-2477bb20257689d4d680701934cdb659c8f6fb37.tar.gz
git-sonar-2477bb20257689d4d680701934cdb659c8f6fb37.zip
Use git-precheck to determine if we are inside a repository
Use the more robust check implemented by the new git-precheck script, instead of the previous dot_git() logic which checks for a ".git" folder with fallback to git-rev-parse. There is still more work to be done though in refactoring this area of the git-sonar script. Due to the specifics of this new implementation, git-sonar will no longer attempt to operate inside a .git directory or a bare git repository. This makes more sense to me, since git-sonar is intended to be an aid during active development work or branch management from within a working tree. This also avoids some other issues and potential edge cases within the script that fail to run properly in those contexts. git-precheck exits with a code of 3 or less if it successfully determines we are inside a valid git repository working tree, so simply assert this in the is_repo function. Signed-off-by: Matt Hunter <m@lfurio.us>
-rwxr-xr-xgit-sonar7
1 files changed, 2 insertions, 5 deletions
diff --git a/git-sonar b/git-sonar
index f957b73..8917cab 100755
--- a/git-sonar
+++ b/git-sonar
@@ -90,11 +90,8 @@ dot_git() {
}
is_repo() {
- if [[ -n "$(dot_git)" ]]; then
- return 0
- else
- return 1
- fi
+ git-precheck --quiet
+ [ $? -lt 4 ]
}
record_timestamp() {