Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

respect indentation on version bump #2514

Merged
merged 6 commits into from
Nov 13, 2023
Merged
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,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
Loading