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 7
7
script_dir=" $( dirname " $0 " ) "
8
8
files_modified=0
9
9
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
12
12
if [[ " $file " == * .sh ]]; then
13
13
sed " s|PLACEHOLDER|$file |" " $script_dir /patches/sh-files.patch" | git apply
14
14
else
15
15
sed " s|PLACEHOLDER|$file |" " $script_dir /patches/js-files.patch" | git apply
16
16
fi
17
17
files_modified=$(( files_modified + 1 ))
18
18
fi
19
- done < <( git ls-files ' bin/** ' ' scripts/** ' ' src/** ' ' test/** ' | grep -E ' \.(js|ts|mjs|mts|jsx|tsx|c|cpp|h|sh)$ ' )
19
+ done
20
20
21
21
if [ " $files_modified " -eq 0 ]; then
22
22
echo " ✓ All files already have copyright headers"
Original file line number Diff line number Diff line change 4
4
5
5
set -e
6
6
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 "
12
10
fi
13
- done < <( git ls-files ' bin/** ' ' scripts/** ' ' src/** ' ' test/** ' | grep -E ' \.(js|ts|mjs|mts|jsx|tsx|c|cpp|h|sh)$ ' )
11
+ done) )
14
12
15
13
if [ ${# missing_files[@]} -gt 0 ]; then
16
14
echo " ❌ Copyright header check failed."
You can’t perform that action at this time.
0 commit comments