Skip to content

Commit e272027

Browse files
committed
test copyright improvement
1 parent 80b50c5 commit e272027

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

.github/workflows/java.yaml

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,21 @@ jobs:
1717
- name: Check Copyright
1818
env:
1919
EXTENSIONS: "*.java"
20-
COPYRIGHT_STATEMENT: "/**\n * Copyright IBM Corp. 2016\n */"
20+
BASE_COPYRIGHT: "Copyright IBM Corp. 2016"
2121
run: |
22-
for ext in $EXTENSIONS; do
23-
for file in $(find . -type f -name "$ext" ! -path "cics-java-liberty-link-app/*"); do
24-
if ! grep -q "Copyright" "$file"; then
25-
echo -e "$COPYRIGHT_STATEMENT\n$(cat "$file")" > "$file"
26-
fi
27-
done
22+
for ext in "$EXTENSIONS"; do
23+
for file in $(find . -type f -name "$ext" ! -path "cics-java-liberty-link-app/*"); do
24+
echo "Processing file: $file"
25+
LAST_MODIFIED_YEAR=$(git log -1 --format="%ad" --date=format:"%Y" -- "$file")
26+
27+
if ! grep -q "Copyright" "$file"; then
28+
echo -e "/**\n * $BASE_COPYRIGHT\n */\n$(cat "$file")" > "$file"
29+
elif ! grep -q "$LAST_MODIFIED_YEAR" "$file"; then
30+
sed -i "s/$BASE_COPYRIGHT/$BASE_COPYRIGHT, $LAST_MODIFIED_YEAR/" "$file"
31+
fi
32+
done
2833
done
34+
2935
- name: Create Pull Request
3036
uses: peter-evans/create-pull-request@v7
3137
with:

0 commit comments

Comments
 (0)