File tree Expand file tree Collapse file tree 1 file changed +13
-7
lines changed
Expand file tree Collapse file tree 1 file changed +13
-7
lines changed Original file line number Diff line number Diff 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 :
You can’t perform that action at this time.
0 commit comments