mirror of
https://github.com/harness/drone.git
synced 2025-05-04 14:12:15 +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{}
|
output := &bytes.Buffer{}
|
||||||
err := cmd.Run(ctx, command.WithDir(repoPath), command.WithStdout(output))
|
err := cmd.Run(ctx, command.WithDir(repoPath), command.WithStdout(output))
|
||||||
if cErr := command.AsError(err); cErr != nil && cErr.IsExitCode(128) {
|
if cErr := command.AsError(err); cErr != nil && cErr.IsExitCode(128) {
|
||||||
if cErr.IsAmbiguousArgErr() {
|
if cErr.IsAmbiguousArgErr() || cErr.IsBadObject() {
|
||||||
return nil, errors.NotFound("reference %q is ambiguous", ref)
|
return []string{}, nil // return an empty list if reference doesn't exist
|
||||||
}
|
|
||||||
if cErr.IsBadObject() {
|
|
||||||
return nil, errors.NotFound("commit not found")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, processGitErrorf(err, "failed to trigger rev-list command")
|
return nil, processGitErrorf(err, "failed to trigger rev-list command")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user