Skip to content

Commit 052bff0

Browse files
zeripathlafriksguillep2ksapk
authored
Convert plumbing.ErrObjectNotFound to git.ErrNotExist in getCommit (#10862)
Co-authored-by: Lauris BH <[email protected]> Co-authored-by: guillep2k <[email protected]> Co-authored-by: Antoine GIRARD <[email protected]>
1 parent ea67e56 commit 052bff0

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

modules/git/repo_commit.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,15 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
9494
gogitCommit, err := repo.gogitRepo.CommitObject(id)
9595
if err == plumbing.ErrObjectNotFound {
9696
tagObject, err = repo.gogitRepo.TagObject(id)
97+
if err == plumbing.ErrObjectNotFound {
98+
return nil, ErrNotExist{
99+
ID: id.String(),
100+
}
101+
}
97102
if err == nil {
98103
gogitCommit, err = repo.gogitRepo.CommitObject(tagObject.Target)
99104
}
105+
// if we get a plumbing.ErrObjectNotFound here then the repository is broken and it should be 500
100106
}
101107
if err != nil {
102108
return nil, err

0 commit comments

Comments
 (0)