Skip to content

Commit

Permalink
Merge pull request #2514 from mashehu/respect-identation-on-version-bump
Browse files Browse the repository at this point in the history
respect indentation on version bump
  • Loading branch information
mashehu authored Nov 13, 2023
2 parents 3f0bc4c + acf59c6 commit ed68cfe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

### General

- `bump_version` keeps now the indentation level of the updated version entries ([#2514](https://github.com/nf-core/tools/pull/2514))

# [v2.10 - Nickel Ostrich](https://github.com/nf-core/tools/releases/tag/2.10) + [2023-09-25]

### Template
Expand Down
19 changes: 10 additions & 9 deletions nf_core/bump_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,18 @@
import logging
import re
from pathlib import Path
from typing import List, Tuple, Union

import rich.console

import nf_core.utils
from nf_core.utils import Pipeline

log = logging.getLogger(__name__)
stderr = rich.console.Console(stderr=True, force_terminal=nf_core.utils.rich_force_colors())


def bump_pipeline_version(pipeline_obj, new_version):
def bump_pipeline_version(pipeline_obj: Pipeline, new_version: str) -> None:
"""Bumps a pipeline version number.
Args:
Expand All @@ -39,8 +41,8 @@ def bump_pipeline_version(pipeline_obj, new_version):
pipeline_obj,
[
(
rf"version\s*=\s*[\'\"]?{re.escape(current_version)}[\'\"]?",
f"version = '{new_version}'",
rf"(version\s*=\s*['\"]){re.escape(current_version)}(['\"])",
rf"\g<1>{new_version}\g<2>",
)
],
)
Expand Down Expand Up @@ -76,7 +78,7 @@ def bump_pipeline_version(pipeline_obj, new_version):
)


def bump_nextflow_version(pipeline_obj, new_version):
def bump_nextflow_version(pipeline_obj: Pipeline, new_version: str) -> None:
"""Bumps the required Nextflow version number of a pipeline.
Args:
Expand All @@ -99,8 +101,8 @@ def bump_nextflow_version(pipeline_obj, new_version):
pipeline_obj,
[
(
rf"nextflowVersion\s*=\s*[\'\"]?!>={re.escape(current_version)}[\'\"]?",
f"nextflowVersion = '!>={new_version}'",
rf"(nextflowVersion\s*=\s*[\'\"]?!>=\s*)({re.escape(current_version)})([\'\"]?)",
rf"\g<1>{new_version}\g<3>",
)
],
)
Expand All @@ -114,7 +116,7 @@ def bump_nextflow_version(pipeline_obj, new_version):
# example:
# NXF_VER:
# - "20.04.0"
rf"- [\"]{re.escape(current_version)}[\"]",
rf"- \"{re.escape(current_version)}\"",
f'- "{new_version}"',
)
],
Expand All @@ -138,15 +140,14 @@ def bump_nextflow_version(pipeline_obj, new_version):
)


def update_file_version(filename, pipeline_obj, patterns):
def update_file_version(filename: Union[str, Path], pipeline_obj: Pipeline, patterns: List[Tuple[str, str]]) -> None:
"""Updates the version number in a requested file.
Args:
filename (str): File to scan.
pipeline_obj (nf_core.lint.PipelineLint): A PipelineLint object that holds information
about the pipeline contents and build files.
pattern (str): Regex pattern to apply.
newstr (str): The replaced string.
Raises:
ValueError, if the version number cannot be found.
Expand Down

0 comments on commit ed68cfe

Please sign in to comment.