Skip to content

Commit 2a820b5

Browse files
committed
Detect and return ErrNotFound when get commit
1 parent 31d8d73 commit 2a820b5

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"time"
1111
)
1212

13-
const _VERSION = "0.3.5"
13+
const _VERSION = "0.3.6"
1414

1515
func Version() string {
1616
return _VERSION

repo_commit.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ func (repo *Repository) getCommit(id sha1) (*Commit, error) {
9696

9797
data, err := NewCommand("cat-file", "-p", id.String()).RunInDirBytes(repo.Path)
9898
if err != nil {
99+
if strings.Contains(err.Error(), "fatal: Not a valid object name") {
100+
return nil, ErrNotExist{id.String(), ""}
101+
}
99102
return nil, err
100103
}
101104

0 commit comments

Comments
 (0)