mirror of
https://github.com/harness/drone.git
synced 2025-05-03 20:09:04 +08:00
fix: [CODE-2501] Return 200 with an empty list for commits on non-existing references (#3366)
This commit is contained in:
parent
92e39dee79
commit
a75e6ec4ec
@ -189,14 +189,10 @@ func (g *Git) listCommitSHAs(
|
||||
output := &bytes.Buffer{}
|
||||
err := cmd.Run(ctx, command.WithDir(repoPath), command.WithStdout(output))
|
||||
if cErr := command.AsError(err); cErr != nil && cErr.IsExitCode(128) {
|
||||
if cErr.IsAmbiguousArgErr() {
|
||||
return nil, errors.NotFound("reference %q is ambiguous", ref)
|
||||
}
|
||||
if cErr.IsBadObject() {
|
||||
return nil, errors.NotFound("commit not found")
|
||||
if cErr.IsAmbiguousArgErr() || cErr.IsBadObject() {
|
||||
return []string{}, nil // return an empty list if reference doesn't exist
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, processGitErrorf(err, "failed to trigger rev-list command")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user