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 bf62569
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions app/copyright
Original file line number Diff line number Diff line change
Expand Up @@ -24,31 +24,31 @@ readonly \

# 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 bf62569

Please sign in to comment.