-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
Improve git log for debugging #24095
Changes from all commits
4125558
d0a1709
8b5510c
4993a36
a973473
9e02a7e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -209,49 +209,22 @@ func Push(ctx context.Context, repoPath string, opts PushOptions) error { | |||
} else { | ||||
cmd.SetDescription(fmt.Sprintf("push branch %s to %s (force: %t, mirror: %t)", opts.Branch, opts.Remote, opts.Force, opts.Mirror)) | ||||
} | ||||
var outbuf, errbuf strings.Builder | ||||
|
||||
if opts.Timeout == 0 { | ||||
opts.Timeout = -1 | ||||
} | ||||
delvh marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
-214
to
-216
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was worried about removing this, but it seems OK. Line 248 in 6bc3079
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, this code |
||||
|
||||
err := cmd.Run(&RunOpts{ | ||||
Env: opts.Env, | ||||
Timeout: opts.Timeout, | ||||
Dir: repoPath, | ||||
Stdout: &outbuf, | ||||
Stderr: &errbuf, | ||||
}) | ||||
stdout, stderr, err := cmd.RunStdString(&RunOpts{Env: opts.Env, Timeout: opts.Timeout, Dir: repoPath}) | ||||
if err != nil { | ||||
if strings.Contains(errbuf.String(), "non-fast-forward") { | ||||
return &ErrPushOutOfDate{ | ||||
StdOut: outbuf.String(), | ||||
StdErr: errbuf.String(), | ||||
Err: err, | ||||
} | ||||
} else if strings.Contains(errbuf.String(), "! [remote rejected]") { | ||||
err := &ErrPushRejected{ | ||||
StdOut: outbuf.String(), | ||||
StdErr: errbuf.String(), | ||||
Err: err, | ||||
} | ||||
if strings.Contains(stderr, "non-fast-forward") { | ||||
return &ErrPushOutOfDate{StdOut: stdout, StdErr: stderr, Err: err} | ||||
} else if strings.Contains(stderr, "! [remote rejected]") { | ||||
err := &ErrPushRejected{StdOut: stdout, StdErr: stderr, Err: err} | ||||
err.GenerateMessage() | ||||
return err | ||||
} else if strings.Contains(errbuf.String(), "matches more than one") { | ||||
err := &ErrMoreThanOne{ | ||||
StdOut: outbuf.String(), | ||||
StdErr: errbuf.String(), | ||||
Err: err, | ||||
} | ||||
return err | ||||
} else if strings.Contains(stderr, "matches more than one") { | ||||
return &ErrMoreThanOne{StdOut: stdout, StdErr: stderr, Err: err} | ||||
} | ||||
return fmt.Errorf("push failed: %w - %s\n%s", err, stderr, stdout) | ||||
} | ||||
|
||||
if errbuf.Len() > 0 && err != nil { | ||||
return fmt.Errorf("%w - %s", err, errbuf.String()) | ||||
} | ||||
|
||||
return err | ||||
return nil | ||||
} | ||||
|
||||
// GetLatestCommitTime returns time for latest commit in repository (across all branches) | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you mean
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
&&
is rightThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why?
SSH doesn't have
://
…There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SSH without
://
doesn't have password either.