From 2897f52cb8943bab241caa93087452cfa246a53e Mon Sep 17 00:00:00 2001 From: Matthias Zepper Date: Wed, 26 Nov 2025 15:42:51 +0100 Subject: [PATCH 1/5] Add new pre-commit hooks to pipeline template: Exclude large files and check for unresolved merge conflict strings. --- nf_core/pipeline-template/.pre-commit-config.yaml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/nf_core/pipeline-template/.pre-commit-config.yaml b/nf_core/pipeline-template/.pre-commit-config.yaml index b1e5f80e51..21a1b3224a 100644 --- a/nf_core/pipeline-template/.pre-commit-config.yaml +++ b/nf_core/pipeline-template/.pre-commit-config.yaml @@ -25,6 +25,16 @@ repos: subworkflows/(?!local/).*| .*\.snap$ )$ + - id: check-added-large-files + args: [--maxkb=5000] + exclude: | + (?x)^( + .*ro-crate-metadata.json$| + .*\.snap$| + lib/nfcore_external_java_deps.jar$| + docs/.*\.(svg|pdf)$ + )$ + - id: check-merge-conflict - repo: https://github.com/seqeralabs/nf-lint-pre-commit rev: v0.3.0 hooks: From 29fb84e388f5fc565aa86b5ae4429f2fc235a09b Mon Sep 17 00:00:00 2001 From: nf-core-bot Date: Wed, 26 Nov 2025 15:54:12 +0000 Subject: [PATCH 2/5] [automated] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b3e08d70a6..a78ec18b57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -107,6 +107,7 @@ ### Template +- New pre-commit hooks (large files, merge conflicts) in pipeline template ([#3935](https://github.com/nf-core/tools/pull/3935)) - switch to uv and prek for pipeline linting workflow ([#3942](https://github.com/nf-core/tools/pull/3942)) - add schema to devcontainer.json ([#3908](https://github.com/nf-core/tools/pull/3908)) From 6f1494497b04248fca4b2112280c8e9a4a87ae54 Mon Sep 17 00:00:00 2001 From: Matthias Zepper Date: Thu, 27 Nov 2025 16:12:17 +0100 Subject: [PATCH 3/5] Add custom pre-commit hook to check for a pipeline output directory. --- .../.hooks/block_pipeline_outdir.sh | 30 +++++++++++++++++++ .../pipeline-template/.pre-commit-config.yaml | 6 ++++ 2 files changed, 36 insertions(+) create mode 100755 nf_core/pipeline-template/.hooks/block_pipeline_outdir.sh diff --git a/nf_core/pipeline-template/.hooks/block_pipeline_outdir.sh b/nf_core/pipeline-template/.hooks/block_pipeline_outdir.sh new file mode 100755 index 0000000000..fbd2419181 --- /dev/null +++ b/nf_core/pipeline-template/.hooks/block_pipeline_outdir.sh @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# This hook is used to block commits if they include staged files inside a directory +# which also contains a subdirectory called `pipeline_info`. The purpose of this is to +# prevent users from inadvertently committing output from pipeline test runs inside the +# development directory. + +set -e + +# list staged files +staged_files="$(git diff --cached --name-only)" + +status=0 + +for file in $staged_files; do + file_dir=$(dirname "$file") + + # Walk up the directory tree and check if the current directory contains a subdirectory called `pipeline_info` + # or the staged file is itself inside a directory called `pipeline_info`. + while [ "$file_dir" != "." ] && [ "$file_dir" != "/" ]; do + if [ $(basename "$file_dir") == "pipeline_info" ] || [ -d "$file_dir/pipeline_info" ]; then + echo "❌ Commit blocked: Please do not commit output from pipeline test runs to the pipeline code itself." + echo "Use 'git restore --staged ...' to remove the output files from the staging area before proceeding." + status=1 + break + fi + file_dir=$(dirname "$file_dir") + done +done + +exit "$status" diff --git a/nf_core/pipeline-template/.pre-commit-config.yaml b/nf_core/pipeline-template/.pre-commit-config.yaml index 21a1b3224a..bd77d635d8 100644 --- a/nf_core/pipeline-template/.pre-commit-config.yaml +++ b/nf_core/pipeline-template/.pre-commit-config.yaml @@ -41,3 +41,9 @@ repos: - id: nextflow-lint files: '\.nf$|nextflow\.config$' args: ["-output", "json"] + - repo: local + hooks: + - id: block-pipeline-outdir + name: Prevent committing output from pipeline test runs to the pipeline code itself + entry: ./.hooks/block_pipeline_outdir.sh + language: script From 244bf9716f5e1f3d46d11fe2cb27b3e29f00adb8 Mon Sep 17 00:00:00 2001 From: Matthias Zepper Date: Thu, 27 Nov 2025 17:07:37 +0100 Subject: [PATCH 4/5] Add '.hooks/block_pipeline_outdir.sh' to linter group for pipeline customisation in 'template_features.yml'. --- nf_core/pipelines/create/template_features.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/nf_core/pipelines/create/template_features.yml b/nf_core/pipelines/create/template_features.yml index c158263157..19b451fb88 100644 --- a/nf_core/pipelines/create/template_features.yml +++ b/nf_core/pipelines/create/template_features.yml @@ -434,6 +434,7 @@ code_quality: - ".prettierignore" - ".prettierrc.yml" - ".github/workflows/fix-linting.yml" + - ".hooks/block_pipeline_outdir.sh" short_description: "Use code linters" description: "The pipeline will include code linters and CI tests to lint your code: pre-commit, editor-config and prettier." help_text: | From de649c48373aa63e69effec73b80231d4ee08707 Mon Sep 17 00:00:00 2001 From: Matthias Zepper Date: Thu, 11 Dec 2025 12:33:43 +0100 Subject: [PATCH 5/5] Exclude assets folder from file size check. --- nf_core/pipeline-template/.pre-commit-config.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nf_core/pipeline-template/.pre-commit-config.yaml b/nf_core/pipeline-template/.pre-commit-config.yaml index bd77d635d8..c487da7072 100644 --- a/nf_core/pipeline-template/.pre-commit-config.yaml +++ b/nf_core/pipeline-template/.pre-commit-config.yaml @@ -32,7 +32,8 @@ repos: .*ro-crate-metadata.json$| .*\.snap$| lib/nfcore_external_java_deps.jar$| - docs/.*\.(svg|pdf)$ + docs/.*\.(svg|pdf)$| + assets/.*$ )$ - id: check-merge-conflict - repo: https://github.com/seqeralabs/nf-lint-pre-commit