summaryrefslogtreecommitdiffstats
path: root/modules/context
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2019-10-16 14:08:01 +0100
committerLauris BH <lauris@nix.lv>2019-10-16 16:08:01 +0300
commit1b72690cb82302b24f41d2beaa5df5592709f4d3 (patch)
tree1bb286721a78de6cf611cbc2bbdcd7c5eab075c4 /modules/context
parent8f0e63c80a2cd3b4362aa5e5191163e22fae6054 (diff)
downloadgitea-1b72690cb82302b24f41d2beaa5df5592709f4d3.tar.gz
gitea-1b72690cb82302b24f41d2beaa5df5592709f4d3.zip
Ensure that GitRepo is set on Empty repositories (#8539)
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/context')
-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 e891e7b85c..e2aebc019c 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)