Skip to content

Commit

Permalink
Ensure that GitRepo is set on Empty repositories (#8539) (#8541)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zeripath authored and lunny committed Oct 16, 2019
1 parent 0752a38 commit 34b8bec
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions modules/context/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand All @@ -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)
Expand Down

0 comments on commit 34b8bec

Please sign in to comment.