Skip to content

Commit 1b72690

Browse files
zeripathlafriks
authored andcommitted
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
1 parent 8f0e63c commit 1b72690

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

modules/context/repo.go

+8-2
Original file line numberDiff line numberDiff line change
@@ -414,8 +414,8 @@ func RepoAssignment() macaron.Handler {
414414
}
415415
}
416416

417-
// repo is empty and display enable
418-
if ctx.Repo.Repository.IsEmpty || ctx.Repo.Repository.IsBeingCreated() {
417+
// Disable everything when the repo is being created
418+
if ctx.Repo.Repository.IsBeingCreated() {
419419
ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
420420
return
421421
}
@@ -427,6 +427,12 @@ func RepoAssignment() macaron.Handler {
427427
}
428428
ctx.Repo.GitRepo = gitRepo
429429

430+
// Stop at this point when the repo is empty.
431+
if ctx.Repo.Repository.IsEmpty {
432+
ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
433+
return
434+
}
435+
430436
tags, err := ctx.Repo.GitRepo.GetTags()
431437
if err != nil {
432438
ctx.ServerError("GetTags", err)

0 commit comments

Comments
 (0)