From 3cae307599f667d94df2696c4b5a6a95914c942f Mon Sep 17 00:00:00 2001 From: Jeremy Muhlich Date: Wed, 8 Oct 2025 17:21:25 -0400 Subject: [PATCH 1/2] Improve file ignores in workflow file enumeration utils.get_wf_files has logic for parsing .gitignore files and using the patterns there as an ignore list, but it doesn't implement the full semantics of gitignore patterns. This change adds support for trailing slash which should ignore an entire directory, which is important as such patterns are included in the pipeline TEMPLATE .gitignore. Also, relative path handling is implemented in the ignore pattern checking. This means ignore patterns still work correctly when the -d option is given to lint a directory other than the current one. Finally, .git/* is added as an implicit ignore pattern that is always in effect. --- nf_core/utils.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/nf_core/utils.py b/nf_core/utils.py index fe9ec413d7..77b22de5d5 100644 --- a/nf_core/utils.py +++ b/nf_core/utils.py @@ -1648,15 +1648,21 @@ def get_wf_files(wf_path: Path): wf_files = [] + ignore = [".git/*"] try: with open(Path(wf_path, ".gitignore")) as f: - lines = f.read().splitlines() - ignore = [line for line in lines if line and not line.startswith("#")] + for line in f.read().splitlines(): + if not line or line.startswith("#"): + continue + # Make trailing-slash patterns match their entire subtree + line = re.sub("/$", "/*", line) + ignore.append(line) except FileNotFoundError: - ignore = [] + pass for path in Path(wf_path).rglob("*"): - if any(fnmatch.fnmatch(str(path), pattern) for pattern in ignore): + rpath = str(path.relative_to(wf_path)) + if any(fnmatch.fnmatch(rpath, pattern) for pattern in ignore): continue if path.is_file(): wf_files.append(str(path)) From 5c6c50d8e076ef6fbfffafc48d3fa24e7b7e51eb Mon Sep 17 00:00:00 2001 From: Jeremy Muhlich Date: Wed, 8 Oct 2025 21:16:33 -0400 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2e7c3eda6..21f36cb91a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -73,6 +73,7 @@ - Update GitHub Actions ([#3795](https://github.com/nf-core/tools/pull/3795)) - Update pre-commit hook astral-sh/ruff-pre-commit to v0.13.3 ([#3791](https://github.com/nf-core/tools/pull/3791)) - Update pre-commit hook pre-commit/pre-commit-hooks to v6 ([#3797](https://github.com/nf-core/tools/pull/3797)) +- Improve file ignores in workflow file enumeration ([#3820](https://github.com/nf-core/tools/pull/3820)) ## [v3.3.2 - Tungsten Tamarin Patch 2](https://github.com/nf-core/tools/releases/tag/3.3.2) - [2025-07-08]