File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
nf_core/pipeline-template Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+ # This hook is used to block commits if they include staged files inside a directory
3+ # which also contains a subdirectory called `pipeline_info`. The purpose of this is to
4+ # prevent users from inadvertently committing output from pipeline test runs inside the
5+ # development directory.
6+
7+ set -e
8+
9+ # list staged files
10+ staged_files=" $( git diff --cached --name-only) "
11+
12+ status=0
13+
14+ for file in $staged_files ; do
15+ file_dir=$( dirname " $file " )
16+
17+ # Walk up the directory tree and check if the current directory contains a subdirectory called `pipeline_info`
18+ # or the staged file is itself inside a directory called `pipeline_info`.
19+ while [ " $file_dir " != " ." ] && [ " $file_dir " != " /" ]; do
20+ if [ $( basename " $file_dir " ) == " pipeline_info" ] || [ -d " $file_dir /pipeline_info" ]; then
21+ echo " ❌ Commit blocked: Please do not commit output from pipeline test runs to the pipeline code itself."
22+ echo " Use 'git restore --staged <file>...' to remove the output files from the staging area before proceeding."
23+ status=1
24+ break
25+ fi
26+ file_dir=$( dirname " $file_dir " )
27+ done
28+ done
29+
30+ exit " $status "
Original file line number Diff line number Diff line change 3535 docs/.*\.(svg|pdf)$
3636 )$
3737 - id : check-merge-conflict
38+ - repo : local
39+ hooks :
40+ - id : block-pipeline-outdir
41+ name : Prevent committing output from pipeline test runs to the pipeline code itself
42+ entry : ./.hooks/block_pipeline_outdir.sh
43+ language : script
You can’t perform that action at this time.
0 commit comments