mirror of
				https://github.com/go-gitea/gitea
				synced 2025-11-04 05:18:25 +00:00 
			
		
		
		
	Fix possible panic when repository is empty (#20509)
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		@@ -896,11 +896,15 @@ func renderCode(ctx *context.Context) {
 | 
				
			|||||||
	ctx.Data["PageIsViewCode"] = true
 | 
						ctx.Data["PageIsViewCode"] = true
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if ctx.Repo.Repository.IsEmpty {
 | 
						if ctx.Repo.Repository.IsEmpty {
 | 
				
			||||||
		reallyEmpty, err := ctx.Repo.GitRepo.IsEmpty()
 | 
							reallyEmpty := true
 | 
				
			||||||
 | 
							var err error
 | 
				
			||||||
 | 
							if ctx.Repo.GitRepo != nil {
 | 
				
			||||||
 | 
								reallyEmpty, err = ctx.Repo.GitRepo.IsEmpty()
 | 
				
			||||||
			if err != nil {
 | 
								if err != nil {
 | 
				
			||||||
				ctx.ServerError("GitRepo.IsEmpty", err)
 | 
									ctx.ServerError("GitRepo.IsEmpty", err)
 | 
				
			||||||
				return
 | 
									return
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		if reallyEmpty {
 | 
							if reallyEmpty {
 | 
				
			||||||
			ctx.HTML(http.StatusOK, tplRepoEMPTY)
 | 
								ctx.HTML(http.StatusOK, tplRepoEMPTY)
 | 
				
			||||||
			return
 | 
								return
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user