Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- add pre-commit hook to keep uv.lock in sync ([#3933](https://github.com/nf-core/tools/pull/3933))
- Fix quote handling in meta.yml ([#3948](https://github.com/nf-core/tools/pull/3948))
- 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))
- handle type for val in topics correctly ([#3991](https://github.com/nf-core/tools/pull/3991))
- Update docker/login-action digest to c94ce9f ([#3998](https://github.com/nf-core/tools/pull/3998))
- fix wrong parsing when output values contain spaces ([#3999](https://github.com/nf-core/tools/pull/3999))
Expand Down
2 changes: 1 addition & 1 deletion nf_core/pipelines/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
+ [
Expand Down
21 changes: 21 additions & 0 deletions tests/pipelines/test_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading