mirror of https://github.com/gogs/gogs.git
repo/commit: improve error detection
Response 404 not 500 for raw diff if object does not exist.pull/3742/merge
parent
55afc1ad21
commit
41c8e87be8
|
@ -179,14 +179,14 @@ func Diff(ctx *context.Context) {
|
|||
ctx.HTML(200, DIFF)
|
||||
}
|
||||
|
||||
func RawDiff(ctx *context.Context) {
|
||||
func RawDiff(c *context.Context) {
|
||||
if err := git.GetRawDiff(
|
||||
models.RepoPath(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name),
|
||||
ctx.Params(":sha"),
|
||||
git.RawDiffType(ctx.Params(":ext")),
|
||||
ctx.Resp,
|
||||
models.RepoPath(c.Repo.Owner.Name, c.Repo.Repository.Name),
|
||||
c.Params(":sha"),
|
||||
git.RawDiffType(c.Params(":ext")),
|
||||
c.Resp,
|
||||
); err != nil {
|
||||
ctx.Handle(500, "GetRawDiff", err)
|
||||
c.NotFoundOrServerError("GetRawDiff", git.IsErrNotExist, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,10 +159,10 @@
|
|||
"revisionTime": "2016-08-10T03:50:02Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "iZ3qMzzA24U3eqGifUZa6kFuCqk=",
|
||||
"checksumSHA1": "XT0fyELKMKgb4XeMAtIrmi4SetM=",
|
||||
"path": "github.com/gogits/git-module",
|
||||
"revision": "5dba4f883034198eabac620b73aabf5488fcd821",
|
||||
"revisionTime": "2017-04-04T05:34:13Z"
|
||||
"revision": "2a496cad1f36aed60b14844b33b68eb3edfc2718",
|
||||
"revisionTime": "2017-04-04T05:59:12Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "D2kVXl0QpIw6t3891Sl7IM9wL+w=",
|
||||
|
|
Loading…
Reference in New Issue