-
Notifications
You must be signed in to change notification settings - Fork 220
Pipeline template: New pre-commit hooks (large files, merge conflicts) #3935
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
base: dev
Are you sure you want to change the base?
Changes from all commits
404aab1
1189649
77540e2
1b149f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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 <file>...' to remove the output files from the staging area before proceeding." | ||
| status=1 | ||
| break | ||
| fi | ||
| file_dir=$(dirname "$file_dir") | ||
| done | ||
| done | ||
|
|
||
| exit "$status" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,3 +25,19 @@ repos: | |
| subworkflows/nf-core/.*| | ||
| .*\.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 | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we have already https://nf-co.re/docs/nf-core-tools/api_reference/dev/pipeline_lint_tests/merge_markers, but this is a nicer approach
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main motivation for this PR was evidently the check-added-large-files. Phil just recommended to use the other one as well, because he has it on the MultiQC repo. If you think that I shouldn't bundle them in one PR to allow separate decisions, I am fine with removing it as well. |
||
| - 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 | ||
Uh oh!
There was an error while loading. Please reload this page.