diff --git a/clients/git/client.go b/clients/git/client.go index d09b0f3..315571b 100644 --- a/clients/git/client.go +++ b/clients/git/client.go @@ -2,7 +2,6 @@ package git import ( "errors" - "fmt" "os" "os/exec" "regexp" @@ -53,8 +52,6 @@ func Clone(url, targetDir string) error { // Include the git output in the error message return clierrors.WrapError("git clone failed: "+string(output), err) } - // Print output on success - fmt.Print(string(output)) return nil } diff --git a/cmd/app/helper.go b/cmd/app/helper.go index b4a183c..f17a985 100644 --- a/cmd/app/helper.go +++ b/cmd/app/helper.go @@ -1,6 +1,7 @@ package app import ( + stderrors "errors" "fmt" "os" "os/exec" @@ -94,13 +95,12 @@ func cloneRepository(sshURL, httpsURL, targetDir string) (string, error) { } // isGitAuthError checks if the error is related to git authentication/permission issues +// It checks all wrapped errors in the chain, not just the top-level error func isGitAuthError(err error) bool { if err == nil { return false } - errMsg := strings.ToLower(err.Error()) - // Common git authentication error patterns authErrorPatterns := []string{ "repository not found", // Catches "ERROR: Repository not found." @@ -113,9 +113,13 @@ func isGitAuthError(err error) bool { "fatal: unable to access", } - for _, pattern := range authErrorPatterns { - if strings.Contains(errMsg, pattern) { - return true + // Check all errors in the chain + for e := err; e != nil; e = stderrors.Unwrap(e) { + errMsg := strings.ToLower(e.Error()) + for _, pattern := range authErrorPatterns { + if strings.Contains(errMsg, pattern) { + return true + } } }