From c9cf6980af9b84f68f613eee71732da8db0f950a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Rahn?= <1529364+rrahn@users.noreply.github.com> Date: Fri, 16 Jan 2026 14:53:23 +0100 Subject: [PATCH 1/2] Escape original merge branch to compile regex --- nf_core/pipelines/sync.py | 2 +- tests/pipelines/test_sync.py | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/nf_core/pipelines/sync.py b/nf_core/pipelines/sync.py index 7ce358cd07..ee4dd1a8bf 100644 --- a/nf_core/pipelines/sync.py +++ b/nf_core/pipelines/sync.py @@ -371,7 +371,7 @@ def create_merge_base_branch(self): # Check if branch exists already branch_list = [b.name for b in self.repo.branches] if self.merge_branch in branch_list: - merge_branch_format = re.compile(rf"{self.original_merge_branch}-(\d+)") + merge_branch_format = re.compile(rf"{re.escape(self.original_merge_branch)}-(\d+)") max_branch = max( [1] + [ diff --git a/tests/pipelines/test_sync.py b/tests/pipelines/test_sync.py index 746b2db76a..b32f21d3ee 100644 --- a/tests/pipelines/test_sync.py +++ b/tests/pipelines/test_sync.py @@ -396,6 +396,27 @@ def test_create_merge_base_branch_thrice(self): for branch_no in [2, 3]: assert f"{psync.original_merge_branch}-{branch_no}" in psync.repo.branches + def test_create_merge_base_branch_with_special_characters(self): + """Test that branch names with regex special characters (like +) are handled correctly. + + This tests that the fix using re.escape() works properly when the version + contains characters that have special meaning in regex patterns (e.g., '+' in '3.6.0.dev0+local0'). + Without re.escape(), the '+' would be interpreted as a regex quantifier instead of a literal character. + """ + psync = nf_core.pipelines.sync.PipelineSync(self.pipeline_dir) + psync.inspect_sync_dir() + psync.get_wf_config() + + psync.original_merge_branch = "nf-core-template-merge-3.6.0.dev0+local0" + psync.merge_branch = psync.original_merge_branch + + for _ in range(3): + psync.create_merge_base_branch() + + assert psync.merge_branch in psync.repo.branches + for branch_no in [2, 3]: + assert f"{psync.original_merge_branch}-{branch_no}" in psync.repo.branches + def test_push_merge_branch(self): """Try pushing merge branch""" psync = nf_core.pipelines.sync.PipelineSync(self.pipeline_dir) From 6d30c03780985722a503a09bec7977213915f745 Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Fri, 16 Jan 2026 14:02:15 +0000 Subject: [PATCH 2/2] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 724311e744..c28ba88d9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - Update astral-sh/setup-uv digest to ed21f2f ([#3959](https://github.com/nf-core/tools/pull/3959)) - Update codecov/codecov-action digest to 671740a ([#3962](https://github.com/nf-core/tools/pull/3962)) - Add support for SVG files in bump-version command ([#3978](https://github.com/nf-core/tools/pull/3978)) +- Escape original merge branch to compile regex ([#3984](https://github.com/nf-core/tools/pull/3984)) ### Template