@@ -532,7 +532,7 @@ func DeleteBranch(ctx context.Context, doer *user_model.User, repo *repo_model.R
532532 // database branch record not exist or it's a deleted branch
533533 notExist := git_model .IsErrBranchNotExist (err ) || rawBranch .IsDeleted
534534
535- commit , err := gitRepo .GetBranchCommit (branchName )
535+ branchCommit , err := gitRepo .GetBranchCommit (branchName )
536536 if err != nil && ! errors .Is (err , util .ErrNotExist ) {
537537 return err
538538 }
@@ -549,7 +549,7 @@ func DeleteBranch(ctx context.Context, doer *user_model.User, repo *repo_model.R
549549 return fmt .Errorf ("DeleteBranch: %v" , err )
550550 }
551551 }
552- if commit == nil {
552+ if branchCommit == nil {
553553 return nil
554554 }
555555
@@ -560,22 +560,24 @@ func DeleteBranch(ctx context.Context, doer *user_model.User, repo *repo_model.R
560560 return err
561561 }
562562
563- if commit != nil {
564- objectFormat := git .ObjectFormatFromName (repo .ObjectFormatName )
563+ if branchCommit == nil {
564+ return nil
565+ }
565566
566- // Don't return error below this
567- if err := PushUpdate (
568- & repo_module.PushUpdateOptions {
569- RefFullName : git .RefNameFromBranch (branchName ),
570- OldCommitID : commit .ID .String (),
571- NewCommitID : objectFormat .EmptyObjectID ().String (),
572- PusherID : doer .ID ,
573- PusherName : doer .Name ,
574- RepoUserName : repo .OwnerName ,
575- RepoName : repo .Name ,
576- }); err != nil {
577- log .Error ("Update: %v" , err )
578- }
567+ // Don't return error below this
568+
569+ objectFormat := git .ObjectFormatFromName (repo .ObjectFormatName )
570+ if err := PushUpdate (
571+ & repo_module.PushUpdateOptions {
572+ RefFullName : git .RefNameFromBranch (branchName ),
573+ OldCommitID : commit .ID .String (),
574+ NewCommitID : objectFormat .EmptyObjectID ().String (),
575+ PusherID : doer .ID ,
576+ PusherName : doer .Name ,
577+ RepoUserName : repo .OwnerName ,
578+ RepoName : repo .Name ,
579+ }); err != nil {
580+ log .Error ("PushUpdateOptions: %v" , err )
579581 }
580582
581583 return nil
0 commit comments