Skip to content

Commit 81a4774

Browse files
author
Fabiana Severin
committed
Changing add headers and check headers
1 parent 1706f42 commit 81a4774

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

scripts/add-headers.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@ set -e
77
script_dir="$(dirname "$0")"
88
files_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

2121
if [ "$files_modified" -eq 0 ]; then
2222
echo "✓ All files already have copyright headers"

scripts/check-headers.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,11 @@
44

55
set -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
1513
if [ ${#missing_files[@]} -gt 0 ]; then
1614
echo "❌ Copyright header check failed."

0 commit comments

Comments
 (0)