From a75e6ec4ec1e39f28a7e35a3bf1b96661f204093 Mon Sep 17 00:00:00 2001 From: Atefeh Mohseni Ejiyeh Date: Sat, 1 Feb 2025 02:28:29 +0000 Subject: [PATCH] fix: [CODE-2501] Return 200 with an empty list for commits on non-existing references (#3366) --- git/api/commit.go | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/git/api/commit.go b/git/api/commit.go index d507bbc4d..592004567 100644 --- a/git/api/commit.go +++ b/git/api/commit.go @@ -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") }