mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-11-03 20:36:07 +01:00 
			
		
		
		
	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
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user