Skip to content

Commit

Permalink
Copyright: Improve code readability
Browse files Browse the repository at this point in the history
  • Loading branch information
rdavid committed Nov 26, 2023
1 parent 9f0d10d commit 493f620
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -19,36 +19,36 @@ BASE_APP_USAGE="$(
readonly \
BASE_APP_USAGE \
BASE_APP_VERSION=0.9.20231126 \
BASE_MIN_VERSION=0.9.20230405
BASE_MIN_VERSION=0.9.20231111
. base.sh

# Analyzes input files, fixes copyright years if needed.
fix_outdated() {
local arg copyrighted modified ret=0
local arg dst src ret=0
for arg; do
modified="$(git log -1 --pretty=format:'%aD' "$arg" | cut -d \ -f 4)"
copyrighted="$(
dst="$(git log -1 --pretty=format:'%aD' "$arg" | cut -d \ -f 4)"
src="$(
grep -E "$PATTERN" <"$arg" |
grep -Eo '[0-9]{4}' |
tail -n 1
)"
[ "$modified" = "$copyrighted" ] && {
log "$arg: copyrighted $copyrighted."
[ "$dst" = "$src" ] && {
log "$arg: copyrighted $src."
continue
}
[ "$ACTION" = false ] && {
ret=1
logw "$arg: copyrighted $copyrighted, modified $modified."
logw "$arg: copyrighted $src, modified $dst."
continue
}
sed -i.bak \
"s/^\(.*\)-$copyrighted\(.*\)$OWNER/\1-$modified\2$OWNER/g" \
"s/^\(.*\)-$src\(.*\)$OWNER/\1-$dst\2$OWNER/g" \
"$arg"
sed -i.bak \
"s/^\(.*\)$copyrighted\(.*\)$OWNER/\1$copyrighted-$modified\2$OWNER/g" \
"s/^\(.*\)$src\(.*\)$OWNER/\1$src-$dst\2$OWNER/g" \
"$arg"
rm "$arg".bak
log "$arg: copyrighted $copyrighted, modified $modified, fixed."
log "$arg: copyrighted $src, modified $dst, fixed."
done
return $ret
}
Expand Down

0 comments on commit 493f620

Please sign in to comment.