Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 4 commits into from
Mar 28, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions modules/git/repo_commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,18 @@ func (repo *Repository) getCommit(id SHA1) (*Commit, error) {
gogitCommit, err := repo.gogitRepo.CommitObject(id)
if err == plumbing.ErrObjectNotFound {
tagObject, err = repo.gogitRepo.TagObject(id)
if err == plumbing.ErrObjectNotFound {
return nil, ErrNotExist{
ID: id.String(),
}
}
if err == nil {
gogitCommit, err = repo.gogitRepo.CommitObject(tagObject.Target)
}
// if we get a plumbing.ErrObjectNotFound here then the repository is broken and it should be 500
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although I'd prefer a "your repository is broken" error. 😉

}
if err != nil {

lafriks marked this conversation as resolved.
Show resolved Hide resolved
lafriks marked this conversation as resolved.
Show resolved Hide resolved
return nil, err
}

Expand Down