summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-10-16 17:03:25 +0100
committerLunny Xiao <xiaolunwen@gmail.com>2019-10-17 00:03:25 +0800
commit34b8becef074bfe3487624642d669dfd4acaeb87 (patch)
treecb874f756be4c5cf216d794b15bd31de968b0bea /modules
parent0752a3895ab5a1aeabe347e2c108e2f1b2a609e6 (diff)
downloadgitea-34b8becef074bfe3487624642d669dfd4acaeb87.tar.gz
gitea-34b8becef074bfe3487624642d669dfd4acaeb87.zip
Ensure that GitRepo is set on Empty repositories (#8539) (#8541)
Both issues/new and settings/hooks/git expect `ctx.Repo.GitRepo` to be set. This PR changes the context code to open the GitRepo. Fixes #8538
Diffstat (limited to 'modules')
-rw-r--r--modules/context/repo.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/context/repo.go b/modules/context/repo.go
index f4af19a0e8..22263c60bd 100644
--- a/modules/context/repo.go
+++ b/modules/context/repo.go
@@ -414,8 +414,8 @@ func RepoAssignment() macaron.Handler {
}
}
- // repo is empty and display enable
- if ctx.Repo.Repository.IsEmpty || ctx.Repo.Repository.IsBeingCreated() {
+ // Disable everything when the repo is being created
+ if ctx.Repo.Repository.IsBeingCreated() {
ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
return
}
@@ -427,6 +427,12 @@ func RepoAssignment() macaron.Handler {
}
ctx.Repo.GitRepo = gitRepo
+ // Stop at this point when the repo is empty.
+ if ctx.Repo.Repository.IsEmpty {
+ ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
+ return
+ }
+
tags, err := ctx.Repo.GitRepo.GetTags()
if err != nil {
ctx.ServerError("GetTags", err)