Skip to content

Commit

Permalink
release-tools/do-copyright-year: Always update copyright year in READ…
Browse files Browse the repository at this point in the history
…ME.md

The copyright in README.md is supposed to have global scope.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #159)
  • Loading branch information
DimitriPapadopoulos authored and t8m committed Sep 11, 2023
1 parent fccdc29 commit 861d005
Showing 1 changed file with 48 additions and 38 deletions.
86 changes: 48 additions & 38 deletions release-tools/do-copyright-year
Original file line number Diff line number Diff line change
Expand Up @@ -27,44 +27,54 @@ s|(${some_year})-\1|\1|
}
EOF

NYD=`date +%Y-01-01`
echo Updating copryight
git diff-tree -r --name-status `git rev-list -1 --before=$NYD HEAD`..HEAD | \
grep -v '^ *D' | \
(
count=0
sp="/-\|"
sc=0
spin() {
printf "\r${sp:sc++:1} %s" "$@"
((sc==${#sp})) && sc=0
}
endspin() {
printf "\r%s\n" "$@"
}
collect_files() {
NYD=`date +%Y-01-01`

git diff-tree -r --name-status `git rev-list -1 --before=$NYD HEAD`..HEAD | \
grep -v '^ *D'

# Always update the end year in README.md. It might be listed twice,
# but this is hardly a problem, just slightly suboptimal.
echo 'X README.md'
}

while read STATUS FILE ; do
if [ -d "$FILE" ]; then continue; fi
(( count++ ))
spin $count
# To avoid touching the original files when they aren't modified:
#
# 1. Copy the file, to make sure all permissions and other
# copyable attributes are copied as well
# 2. Run sed on the copy
# 3. IF the copy has been modified, move it back to the original,
# add and commit.
TMPFILE="$(dirname "$FILE")"/"__$(basename "$FILE").new"
cp "$FILE" "$TMPFILE"
sed -E -f /tmp/sed$$ -i "$TMPFILE"
if cmp -s "$FILE" "$TMPFILE"; then
rm "$TMPFILE"
else
mv "$TMPFILE" "$FILE"
git add "$FILE"
fi
done
endspin "Files considered: $count"
)
process_files() {
count=0
sp="/-\|"
sc=0
spin() {
printf "\r${sp:sc++:1} %s" "$@"
((sc==${#sp})) && sc=0
}
endspin() {
printf "\r%s\n" "$@"
}

while read STATUS FILE ; do
if [ -d "$FILE" ]; then continue; fi
(( count++ ))
spin $count
# To avoid touching the original files when they aren't modified:
#
# 1. Copy the file, to make sure all permissions and other
# copyable attributes are copied as well
# 2. Run sed on the copy
# 3. IF the copy has been modified, move it back to the original,
# add and commit.
TMPFILE="$(dirname "$FILE")"/"__$(basename "$FILE").new"
cp "$FILE" "$TMPFILE"
sed -E -f /tmp/sed$$ -i "$TMPFILE"
if cmp -s "$FILE" "$TMPFILE"; then
rm "$TMPFILE"
else
mv "$TMPFILE" "$FILE"
git add "$FILE"
fi
done
endspin "Files considered: $count"
}

echo Updating copryight
collect_files | process_files
echo Files changed: $(git status --porcelain --untracked-files=no --ignore-submodules=all | grep '^ *M' | wc -l)
rm -f $ss

0 comments on commit 861d005

Please sign in to comment.