mirror of
https://github.com/gogs/gogs.git
synced 2026-06-23 14:22:05 +02:00
repo/commit: improve error detection
Response 404 not 500 for raw diff if object does not exist.
This commit is contained in:
5
vendor/github.com/gogits/git-module/repo_commit.go
generated
vendored
5
vendor/github.com/gogits/git-module/repo_commit.go
generated
vendored
@@ -106,7 +106,7 @@ func (repo *Repository) getCommit(id sha1) (*Commit, error) {
|
||||
|
||||
data, err := NewCommand("cat-file", "-p", id.String()).RunInDirBytes(repo.Path)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "fatal: Not a valid object name") {
|
||||
if strings.Contains(err.Error(), "exit status 128") {
|
||||
return nil, ErrNotExist{id.String(), ""}
|
||||
}
|
||||
return nil, err
|
||||
@@ -129,6 +129,9 @@ func (repo *Repository) GetCommit(commitID string) (*Commit, error) {
|
||||
var err error
|
||||
commitID, err = NewCommand("rev-parse", commitID).RunInDir(repo.Path)
|
||||
if err != nil {
|
||||
if strings.Contains(err.Error(), "exit status 128") {
|
||||
return nil, ErrNotExist{commitID, ""}
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user