diff options
Diffstat (limited to 'routers/api/v1')
-rw-r--r-- | routers/api/v1/repo/branch.go | 7 | ||||
-rw-r--r-- | routers/api/v1/repo/file.go | 5 |
2 files changed, 11 insertions, 1 deletions
diff --git a/routers/api/v1/repo/branch.go b/routers/api/v1/repo/branch.go index 3c73ae62c2..489fbe6b4e 100644 --- a/routers/api/v1/repo/branch.go +++ b/routers/api/v1/repo/branch.go @@ -7,6 +7,7 @@ package repo import ( api "code.gitea.io/sdk/gitea" + "code.gitea.io/gitea/models" "code.gitea.io/gitea/modules/context" "code.gitea.io/gitea/routers/api/v1/convert" ) @@ -16,7 +17,11 @@ import ( func GetBranch(ctx *context.APIContext) { branch, err := ctx.Repo.Repository.GetBranch(ctx.Params(":branchname")) if err != nil { - ctx.Error(500, "GetBranch", err) + if models.IsErrBranchNotExist(err) { + ctx.Error(404, "GetBranch", err) + } else { + ctx.Error(500, "GetBranch", err) + } return } diff --git a/routers/api/v1/repo/file.go b/routers/api/v1/repo/file.go index 16a31f96c7..9d12a6e136 100644 --- a/routers/api/v1/repo/file.go +++ b/routers/api/v1/repo/file.go @@ -20,6 +20,11 @@ func GetRawFile(ctx *context.APIContext) { return } + if ctx.Repo.Repository.IsBare { + ctx.Status(404) + return + } + blob, err := ctx.Repo.Commit.GetBlobByPath(ctx.Repo.TreePath) if err != nil { if git.IsErrNotExist(err) { |