@@ -957,37 +957,21 @@ func CleanUpPullRequest(ctx *context.Context) {
957
957
}
958
958
959
959
// Check if branch has no new commits
960
- if len (pr .MergedCommitID ) > 0 {
961
- branchCommitID , err := gitRepo .GetBranchCommitID (pr .HeadBranch )
962
- if err != nil {
963
- log .Error (4 , "GetBranchCommitID: %v" , err )
964
- ctx .Flash .Error (ctx .Tr ("repo.branch.deletion_failed" , fullBranchName ))
965
- return
966
- }
967
-
968
- commit , err := gitBaseRepo .GetCommit (pr .MergedCommitID )
969
- if err != nil {
970
- log .Error (4 , "GetCommit: %v" , err )
971
- ctx .Flash .Error (ctx .Tr ("repo.branch.deletion_failed" , fullBranchName ))
972
- return
973
- }
974
-
975
- isParent := false
976
- for i := 0 ; i < commit .ParentCount (); i ++ {
977
- if parent , err := commit .Parent (i ); err != nil {
978
- log .Error (4 , "Parent: %v" , err )
979
- ctx .Flash .Error (ctx .Tr ("repo.branch.deletion_failed" , fullBranchName ))
980
- return
981
- } else if parent .ID .String () == branchCommitID {
982
- isParent = true
983
- break
984
- }
985
- }
986
-
987
- if ! isParent {
988
- ctx .Flash .Error (ctx .Tr ("repo.branch.delete_branch_has_new_commits" , fullBranchName ))
989
- return
990
- }
960
+ headCommitID , err := gitBaseRepo .GetRefCommitID (pr .GetGitRefName ())
961
+ if err != nil {
962
+ log .Error (4 , "GetRefCommitID: %v" , err )
963
+ ctx .Flash .Error (ctx .Tr ("repo.branch.deletion_failed" , fullBranchName ))
964
+ return
965
+ }
966
+ branchCommitID , err := gitRepo .GetBranchCommitID (pr .HeadBranch )
967
+ if err != nil {
968
+ log .Error (4 , "GetBranchCommitID: %v" , err )
969
+ ctx .Flash .Error (ctx .Tr ("repo.branch.deletion_failed" , fullBranchName ))
970
+ return
971
+ }
972
+ if headCommitID != branchCommitID {
973
+ ctx .Flash .Error (ctx .Tr ("repo.branch.delete_branch_has_new_commits" , fullBranchName ))
974
+ return
991
975
}
992
976
993
977
if err := gitRepo .DeleteBranch (pr .HeadBranch , git.DeleteBranchOptions {
0 commit comments