fix(branch removal(closing)): added check to avoid deleting(closing) landing branches during PR merge with delete source branch option enabled.
This commit is contained in:
parent
210c96330a
commit
a72f17a204
2 changed files with 15 additions and 2 deletions
|
|
@ -965,6 +965,7 @@ class GitRepository(BaseRepository):
|
|||
log.debug(
|
||||
"Executing merge_repo with %s strategy, dry_run mode:%s", "rebase" if use_rebase else "merge", dry_run
|
||||
)
|
||||
from rhodecode.model.repo import RepoModel
|
||||
|
||||
if target_ref.commit_id != self.branches[target_ref.name]:
|
||||
log.warning(
|
||||
|
|
@ -1056,7 +1057,13 @@ class GitRepository(BaseRepository):
|
|||
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":
|
||||
if (
|
||||
close_branch
|
||||
and RepoModel().get_repo(repo_id).landing_ref_name != source_ref.name
|
||||
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(
|
||||
|
|
|
|||
|
|
@ -813,6 +813,7 @@ class MercurialRepository(BaseRepository):
|
|||
log.debug(
|
||||
"Executing merge_repo with %s strategy, dry_run mode:%s", "rebase" if use_rebase else "merge", dry_run
|
||||
)
|
||||
from rhodecode.model.repo import RepoModel
|
||||
|
||||
if target_ref.commit_id not in self._heads():
|
||||
return MergeResponse(
|
||||
|
|
@ -868,7 +869,12 @@ class MercurialRepository(BaseRepository):
|
|||
close_branch = close_branch and source_ref.name != target_ref.name
|
||||
|
||||
needs_push_on_close = False
|
||||
if close_branch and not use_rebase and not dry_run:
|
||||
if (
|
||||
close_branch
|
||||
and RepoModel().get_repo(repo_id).landing_ref_name != source_ref.name
|
||||
and not use_rebase
|
||||
and not dry_run
|
||||
):
|
||||
try:
|
||||
close_commit_id, needs_push_on_close = shadow_repo._local_close(
|
||||
target_ref, merger_name, merger_email, source_ref
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue