File tree 1 file changed +7
-6
lines changed
1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change 2
2
3
3
set -euo pipefail
4
4
5
- DIR= " $( pwd ) " # hooks are always ran from the root of the repo
5
+ # hooks are always ran from the root of the repo
6
6
7
- submodule_dirs=$( git submodule | awk ' { printf "-not -path ' " $DIR " ' /" $2 "/* " }' )
8
- set -f # disable globbing
7
+ # get all files that have been changed
8
+ all_diff_files=` git diff --name-only --cached --ignore-submodules=all --diff-filter=ACM`
9
+ if [ -z " $all_diff_files " ]; then exit 0; fi
10
+ diff_files=` echo " $all_diff_files " | grep -v /.testsupport/`
9
11
# shellcheck disable=SC2086
10
- sh_files =$( find " $DIR " \( -name ' *.sh ' -or -name ' *.bash ' \) -not -path " $DIR " /.testsupport/ ' * ' $submodule_dirs )
12
+ exec_files =$( find $diff_files -exec sh -c ' head -n1 $1 | grep -qE ' " ' " ' ^#!(.*/|\/usr\/bin\/env +)bash ' " ' " sh {} \; -exec echo {} \; )
11
13
# shellcheck disable=SC2086
12
- exec_files=$( find " $DIR " -not -path " $DIR " /.testsupport/' *' $submodule_dirs -type f -exec sh -c ' head -n1 $1 | grep -qE ' " '" ' ^#!(.*/|\/usr\/bin\/env +)bash' " '" sh {} \; -exec echo {} \; )
13
- set +f
14
+ sh_files=$( find $diff_files \( -name ' *.sh' -or -name ' *.bash' \) )
14
15
all_files=` echo -e " $sh_files \n$exec_files " | sort | uniq`
15
16
# shellcheck disable=SC2086
16
17
shellcheck --shell bash $all_files
You can’t perform that action at this time.
0 commit comments