# HG changeset patch # User Serhii Ilin # Date 2024-06-17 11:59:54 # Node ID df00ef8a7593218a730c552dc1ca097ad2996481 # Parent d936c57c9462d92e381a16fd05f35b375765e65f feat(delete-branch-after-merge-git): added ability to delete a branch automatically after merging PR (if it was configured). Fixes: RCCE-76 diff --git a/rhodecode/lib/vcs/backends/git/repository.py b/rhodecode/lib/vcs/backends/git/repository.py --- a/rhodecode/lib/vcs/backends/git/repository.py +++ b/rhodecode/lib/vcs/backends/git/repository.py @@ -1040,6 +1040,8 @@ class GitRepository(BaseRepository): pr_branch, self.path, target_ref.name, enable_hooks=True, rc_scm_data=self.config.get('rhodecode', 'RC_SCM_DATA')) merge_succeeded = True + if close_branch and source_ref.name != target_ref.name and not dry_run and source_ref.type == 'branch': + self.delete_branch(source_ref.name) except RepositoryError: log.exception( 'Failure when doing local push from the shadow ' diff --git a/rhodecode/templates/base/vcs_settings.mako b/rhodecode/templates/base/vcs_settings.mako --- a/rhodecode/templates/base/vcs_settings.mako +++ b/rhodecode/templates/base/vcs_settings.mako @@ -300,31 +300,30 @@ % endif -## DISABLED FOR GIT FOR NOW as the rebase/close is not supported yet -## % if display_globals or repo_type in ['git']: -##
-##
-##

${_('Git Pull Request Settings')}

-##
-##
-##
-## ${h.checkbox('rhodecode_git_use_rebase_for_merging' + suffix, 'True', **kwargs)} -## -##
-##
-## ${_('Use rebase instead of creating a merge commit when merging via web interface.')} -##
-## -##
-## ${h.checkbox('rhodecode_git_close_branch_before_merging' + suffix, 'True', **kwargs)} -## -##
-##
-## ${_('Delete branch after merging it into destination branch. No effect when rebase strategy is use.')} -##
-##
-##
-## % endif +% if display_globals or repo_type in ['git']: +
+
+

${_('Git Pull Request Settings')}

+
+
+##
+## ${h.checkbox('rhodecode_git_use_rebase_for_merging' + suffix, 'True', **kwargs)} +## +##
+##
+## ${_('Use rebase instead of creating a merge commit when merging via web interface.')} +##
+ +
+ ${h.checkbox('rhodecode_git_close_branch_before_merging' + suffix, 'True', **kwargs)} + +
+
+ ${_('Delete branch after merging it into destination branch.')} +
+
+
+% endif