Convert plumbing.ErrObjectNotFound to git.ErrNotExist in getCommit (#10862)

Co-authored-by: Lauris BH <lauris@nix.lv>
Co-authored-by: guillep2k <18600385+guillep2k@users.noreply.github.com>
Co-authored-by: Antoine GIRARD <sapk@users.noreply.github.com>
release/v1.15
zeripath 2020-03-28 18:59:21 +00:00 committed by GitHub
parent ea67e563dd
commit 052bff0cff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -94,9 +94,15 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
gogitCommit, err := repo.gogitRepo.CommitObject(id) gogitCommit, err := repo.gogitRepo.CommitObject(id)
if err == plumbing.ErrObjectNotFound { if err == plumbing.ErrObjectNotFound {
tagObject, err = repo.gogitRepo.TagObject(id) tagObject, err = repo.gogitRepo.TagObject(id)
if err == plumbing.ErrObjectNotFound {
return nil, ErrNotExist{
ID: id.String(),
}
}
if err == nil { if err == nil {
gogitCommit, err = repo.gogitRepo.CommitObject(tagObject.Target) gogitCommit, err = repo.gogitRepo.CommitObject(tagObject.Target)
} }
// if we get a plumbing.ErrObjectNotFound here then the repository is broken and it should be 500
} }
if err != nil { if err != nil {
return nil, err return nil, err