From d90751160941fa8c14519fcb3c647f26c1ce1a6c Mon Sep 17 00:00:00 2001 From: mashehu Date: Fri, 8 May 2026 13:28:57 +0200 Subject: [PATCH 1/3] forward `--verbose` to prek --- nf_core/pipelines/lint_utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nf_core/pipelines/lint_utils.py b/nf_core/pipelines/lint_utils.py index e1980cf89d..a17477cd8e 100644 --- a/nf_core/pipelines/lint_utils.py +++ b/nf_core/pipelines/lint_utils.py @@ -4,6 +4,7 @@ import sys from pathlib import Path +import click import git import rich import yaml @@ -149,6 +150,12 @@ def run_prettier_on_file(file: Path | str | list[str]) -> None: Warns: If Prettier is not installed, a warning is logged. """ + verbose = False + try: + ctx = click.get_current_context() + verbose = bool(ctx.obj and ctx.obj.get("verbose", False)) + except RuntimeError: + pass is_git = check_git_repo() @@ -160,6 +167,8 @@ def run_prettier_on_file(file: Path | str | list[str]) -> None: prek_bin = Path(sys.executable).parent / "prek" prek = str(prek_bin) if prek_bin.exists() else "prek" args = [prek, "run", "--config", str(nf_core_pre_commit_config), "prettier"] + if verbose: + args.append("--verbose") if isinstance(file, list): args.extend(["--files", *file]) else: From 133076422aa34385490a6745cde84aff9aa992d0 Mon Sep 17 00:00:00 2001 From: mashehu Date: Fri, 8 May 2026 13:30:16 +0200 Subject: [PATCH 2/3] avoid prek input overload, by applying git- and prettieringore rules before handing it to prek --- nf_core/pipelines/create/create.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/nf_core/pipelines/create/create.py b/nf_core/pipelines/create/create.py index b1b9f45594..f99b5798bb 100644 --- a/nf_core/pipelines/create/create.py +++ b/nf_core/pipelines/create/create.py @@ -12,6 +12,7 @@ import git import git.config import jinja2 +import pathspec import yaml import nf_core @@ -26,6 +27,19 @@ log = logging.getLogger(__name__) +def _get_prettier_files(outdir: Path) -> list[str]: + """Return non-gitignored files in outdir, further filtered by .prettierignore if present.""" + repo = git.Repo(outdir) + files = [f for f in repo.git.ls_files("--cached", "--others", "--exclude-standard").splitlines() if f] + + prettierignore = outdir / ".prettierignore" + if prettierignore.exists() and files: + spec = pathspec.PathSpec.from_lines("gitwildmatch", prettierignore.read_text().splitlines()) + files = [f for f in files if not spec.match_file(f)] + + return [str(outdir / f) for f in files] + + class PipelineCreate: """Creates a nf-core pipeline a la carte from the nf-core best-practice template. @@ -281,7 +295,7 @@ def init_pipeline(self): ): current_dir = Path.cwd() os.chdir(self.outdir) - run_prettier_on_file([str(f) for f in self.outdir.glob("**/*")]) + run_prettier_on_file(_get_prettier_files(self.outdir)) os.chdir(current_dir) if self.config.is_nfcore and not self.is_interactive: @@ -399,7 +413,7 @@ def render_template(self) -> None: # Run prettier on files for pipelines sync log.debug("Running prettier on pipeline files") - run_prettier_on_file([str(f) for f in self.outdir.glob("**/*")]) + run_prettier_on_file(_get_prettier_files(self.outdir)) def fix_linting(self): """ From cea43bbe3d4958c319a543b5b44e8e0cadea321a Mon Sep 17 00:00:00 2001 From: mashehu Date: Fri, 8 May 2026 14:20:54 +0200 Subject: [PATCH 3/3] add fall back for non-git repos --- nf_core/pipelines/create/create.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/nf_core/pipelines/create/create.py b/nf_core/pipelines/create/create.py index f99b5798bb..3fd3ecb258 100644 --- a/nf_core/pipelines/create/create.py +++ b/nf_core/pipelines/create/create.py @@ -29,8 +29,11 @@ def _get_prettier_files(outdir: Path) -> list[str]: """Return non-gitignored files in outdir, further filtered by .prettierignore if present.""" - repo = git.Repo(outdir) - files = [f for f in repo.git.ls_files("--cached", "--others", "--exclude-standard").splitlines() if f] + try: + repo = git.Repo(outdir) + files = [f for f in repo.git.ls_files("--cached", "--others", "--exclude-standard").splitlines() if f] + except git.InvalidGitRepositoryError: + files = [str(f.relative_to(outdir)) for f in outdir.rglob("*") if f.is_file()] prettierignore = outdir / ".prettierignore" if prettierignore.exists() and files: