@@ -225,15 +225,28 @@ func prepareRecentlyPushedNewBranches(ctx *context.Context) {
225225
226226func handleRepoEmptyOrBroken (ctx * context.Context ) {
227227 showEmpty := true
228- var err error
229228 if ctx .Repo .GitRepo != nil {
230- showEmpty , err = ctx .Repo .GitRepo .IsEmpty ()
229+ reallyEmpty , err : = ctx .Repo .GitRepo .IsEmpty ()
231230 if err != nil {
232231 log .Error ("GitRepo.IsEmpty: %v" , err )
233232 ctx .Repo .Repository .Status = repo_model .RepositoryBroken
234233 showEmpty = true
235234 ctx .Flash .Error (ctx .Tr ("error.occurred" ), true )
236235 }
236+ if reallyEmpty {
237+ showEmpty = true
238+ } else if ctx .Repo .Commit == nil {
239+ showEmpty = true // it is not really empty, but there is no branch
240+ updateRepo := & repo_model.Repository {ID : ctx .Repo .Repository .ID , IsEmpty : true , Status : repo_model .RepositoryReady }
241+ // at the moment, other repo units like "actions" are not able to handle such case,
242+ // so we just mark the repo as empty to prevent from displaying these units.
243+ if err = repo_model .UpdateRepositoryCols (ctx , updateRepo , "is_empty" , "status" ); err != nil {
244+ ctx .ServerError ("UpdateRepositoryCols" , err )
245+ return
246+ }
247+ } else {
248+ showEmpty = false // the repo is actually not empty and has branches, need to update the database
249+ }
237250 }
238251 if showEmpty {
239252 ctx .HTML (http .StatusOK , tplRepoEMPTY )
@@ -247,11 +260,14 @@ func handleRepoEmptyOrBroken(ctx *context.Context) {
247260 // it's possible for a repository to be non-empty by that flag but still 500
248261 // because there are no branches - only tags -or the default branch is non-extant as it has been 0-pushed.
249262 ctx .Repo .Repository .IsEmpty = false
250- if err = repo_model .UpdateRepositoryCols (ctx , ctx .Repo .Repository , "is_empty" ); err != nil {
263+ if ctx .Repo .Repository .Status == repo_model .RepositoryBroken {
264+ ctx .Repo .Repository .Status = repo_model .RepositoryReady
265+ }
266+ if err := repo_model .UpdateRepositoryCols (ctx , ctx .Repo .Repository , "is_empty" , "status" ); err != nil {
251267 ctx .ServerError ("UpdateRepositoryCols" , err )
252268 return
253269 }
254- if err = repo_module .UpdateRepoSize (ctx , ctx .Repo .Repository ); err != nil {
270+ if err : = repo_module .UpdateRepoSize (ctx , ctx .Repo .Repository ); err != nil {
255271 ctx .ServerError ("UpdateRepoSize" , err )
256272 return
257273 }
0 commit comments