mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 16:40:24 +08:00 
			
		
		
		
	* Refactor repo.isBare to repo.isEmpty #5629 Signed-off-by: Andrew Thornton <art27@cantab.net> * Remove Sync call
This commit is contained in:
		@@ -124,7 +124,7 @@ func APIContexter() macaron.Handler {
 | 
			
		||||
func ReferencesGitRepo() macaron.Handler {
 | 
			
		||||
	return func(ctx *APIContext) {
 | 
			
		||||
		// Empty repository does not have reference information.
 | 
			
		||||
		if ctx.Repo.Repository.IsBare {
 | 
			
		||||
		if ctx.Repo.Repository.IsEmpty {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -234,7 +234,7 @@ func repoAssignment(ctx *Context, repo *models.Repository) {
 | 
			
		||||
 | 
			
		||||
	ctx.Repo.Repository = repo
 | 
			
		||||
	ctx.Data["RepoName"] = ctx.Repo.Repository.Name
 | 
			
		||||
	ctx.Data["IsBareRepo"] = ctx.Repo.Repository.IsBare
 | 
			
		||||
	ctx.Data["IsEmptyRepo"] = ctx.Repo.Repository.IsEmpty
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// RepoIDAssignment returns a macaron handler which assigns the repo to the context.
 | 
			
		||||
@@ -370,8 +370,8 @@ func RepoAssignment() macaron.Handler {
 | 
			
		||||
			ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.ID, repo.ID)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// repo is bare and display enable
 | 
			
		||||
		if ctx.Repo.Repository.IsBare {
 | 
			
		||||
		// repo is empty and display enable
 | 
			
		||||
		if ctx.Repo.Repository.IsEmpty {
 | 
			
		||||
			ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
@@ -520,7 +520,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
 | 
			
		||||
func RepoRefByType(refType RepoRefType) macaron.Handler {
 | 
			
		||||
	return func(ctx *Context) {
 | 
			
		||||
		// Empty repository does not have reference information.
 | 
			
		||||
		if ctx.Repo.Repository.IsBare {
 | 
			
		||||
		if ctx.Repo.Repository.IsEmpty {
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
@@ -549,7 +549,7 @@ func RepoRefByType(refType RepoRefType) macaron.Handler {
 | 
			
		||||
					ctx.ServerError("GetBranches", err)
 | 
			
		||||
					return
 | 
			
		||||
				} else if len(brs) == 0 {
 | 
			
		||||
					err = fmt.Errorf("No branches in non-bare repository %s",
 | 
			
		||||
					err = fmt.Errorf("No branches in non-empty repository %s",
 | 
			
		||||
						ctx.Repo.GitRepo.Path)
 | 
			
		||||
					ctx.ServerError("GetBranches", err)
 | 
			
		||||
					return
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user