Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error messages for cloning failures #284

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

taylor-sutton
Copy link
Contributor

JIRA

https://clever.atlassian.net/browse/INFRANG-6515 (Internal Link)

Overview

When cloning fails, show the actual error output from git in the clone status.

Testing

Tested by using an init from file with a repo that doesn't exist and one with an invalid name (trailing space as per Jira ticket). Beforehand, the error message is simply exit status 128. Afterwords, it contains the actual git error.

@taylor-sutton taylor-sutton requested a review from a team as a code owner January 6, 2025 13:54
@taylor-sutton taylor-sutton requested review from andruwm and removed request for a team January 6, 2025 13:54
clone/clone.go Outdated
func Clone(ctx context.Context, input Input) (Output, error) {
cloneIntoDir := path.Join(input.WorkDir, "cloned")
if _, err := os.Stat(cloneIntoDir); err == nil {
// already cloned
return Output{Success: true, ClonedIntoDir: cloneIntoDir}, nil
}

cmd := exec.CommandContext(ctx, "git", "clone", input.GitURL, cloneIntoDir)
cmd := exec.CommandContext(ctx, "git", "clone", "--quiet", input.GitURL, cloneIntoDir)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the purpose of the --quiet addition?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I thought it was worth having more focused output on error but it does seem like in most error cases it's not too much output and we can let the user look over the full (non quiet) log.

For example the non-quiet output for the whitespace issues is:

2025/01/06 10:20:18 exit status 128:
Cloning into '/Users/taylor.sutton/go/src/github.com/Clever/microplane/mp/catapult /clone/cloned'...
fatal: remote error: 
 Clever/catapult  is not a valid repository name
Visit https://support.github.com/ for help

and the quiet output just removes one line

2025/01/06 10:20:18 exit status 128:
fatal: remote error: 
 Clever/catapult  is not a valid repository name
Visit https://support.github.com/ for help

So I'll remove the quiet.

@taylor-sutton taylor-sutton force-pushed the INFRANG-6515-error-messages branch from 65145f2 to a1b3ae7 Compare January 6, 2025 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants