From bd8a84397221636184bb5c61d3e7a5c32bd6880e Mon Sep 17 00:00:00 2001 From: Pasha Sviderski Date: Fri, 31 Oct 2025 17:17:29 +1000 Subject: [PATCH] chore: inspecrt git state without an error if git utility not available --- internal/gitutil/state.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/internal/gitutil/state.go b/internal/gitutil/state.go index b64dcf32..1dffc0a8 100644 --- a/internal/gitutil/state.go +++ b/internal/gitutil/state.go @@ -8,7 +8,7 @@ import ( "time" ) -// GitState contains raw information about the Git repository state. +// GitState contains information about the Git repository state. type GitState struct { // IsDirty indicates whether there are uncommitted changes. IsDirty bool @@ -21,12 +21,17 @@ type GitState struct { } // InspectGitState inspects the Git repo state from the specified directory. -// If the directory is not a Git repository, returns GitState with IsRepo=false. +// If the directory is not a Git repository, or if git utility is not available, +// returns GitState with IsRepo=false and no error. func InspectGitState(dir string) (GitState, error) { + // Check if git command is available. + if _, err := exec.LookPath("git"); err != nil { + return GitState{}, nil + } + state := GitState{ IsRepo: isGitRepo(dir), } - if !state.IsRepo { return state, nil }