File tree Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Expand file tree Collapse file tree 2 files changed +7
-9
lines changed Original file line number Diff line number Diff line change 77script_dir=" $( dirname " $0 " ) "
88files_modified=0
99
10- while IFS= read -r file ; do
11- if ! grep -q ' Copyright.*Amazon\.com' " $file " ; then
10+ for file in $( git diff --name-only --diff-filter=M HEAD -- ' bin/** ' ' scripts/** ' ' src/** ' ' test/** ' | grep -E ' \.(js|ts|mjs|mts|jsx|tsx|c|cpp|h|sh)$ ' ) ; do
11+ if ! git show HEAD: " $file " 2> /dev/null | grep -q ' Copyright.*Amazon\.com' ; then
1212 if [[ " $file " == * .sh ]]; then
1313 sed " s|PLACEHOLDER|$file |" " $script_dir /patches/sh-files.patch" | git apply
1414 else
1515 sed " s|PLACEHOLDER|$file |" " $script_dir /patches/js-files.patch" | git apply
1616 fi
1717 files_modified=$(( files_modified + 1 ))
1818 fi
19- done < <( git ls-files ' bin/** ' ' scripts/** ' ' src/** ' ' test/** ' | grep -E ' \.(js|ts|mjs|mts|jsx|tsx|c|cpp|h|sh)$ ' )
19+ done
2020
2121if [ " $files_modified " -eq 0 ]; then
2222 echo " ✓ All files already have copyright headers"
Original file line number Diff line number Diff line change 44
55set -e
66
7- missing_files=()
8-
9- while IFS= read -r file; do
10- if ! grep -q ' Copyright.*Amazon\.com' " $file " ; then
11- missing_files+=(" $file " )
7+ missing_files=($( git diff --name-only --diff-filter=M HEAD -- ' bin/**' ' scripts/**' ' src/**' ' test/**' | grep -E ' \.(js|ts|mjs|mts|jsx|tsx|c|cpp|h|sh)$' | while read -r file; do
8+ if ! git show HEAD:" $file " 2> /dev/null | grep -q ' Copyright.*Amazon\.com' ; then
9+ echo " $file "
1210 fi
13- done < <( git ls-files ' bin/** ' ' scripts/** ' ' src/** ' ' test/** ' | grep -E ' \.(js|ts|mjs|mts|jsx|tsx|c|cpp|h|sh)$ ' )
11+ done) )
1412
1513if [ ${# missing_files[@]} -gt 0 ]; then
1614 echo " ❌ Copyright header check failed."
You can’t perform that action at this time.
0 commit comments