Skip to content

Instantly share code, notes, and snippets.

@romain-grecourt
Last active July 16, 2023 08:40
Show Gist options
  • Save romain-grecourt/bc6d63863da0e16c1b96e1ad5b5641ba to your computer and use it in GitHub Desktop.
Save romain-grecourt/bc6d63863da0e16c1b96e1ad5b5641ba to your computer and use it in GitHub Desktop.
Update copyright year.
@Tomas-Kraus
Copy link

Version for 2023 Helidon copyright. :)

#!/bin/bash -e
#
# arg1, file with lines of copyright errors from wercker
# e.g.
# /pipeline/source/pom.xml: Copyright year is wrong; is 2019, should be 2020
#
# NOTES:
# - stash any local changes before running this script
# - check the result with `git status`
# - if needed, revert changes with `git reset --hard`

COPYRIGHT_PREFIX="Copyright \(c\)"
COPYRIGHT_SUFFIX="Oracle and/or its affiliates."
COPYRIGHT_YEAR="2023"

update_copyright() {
   sed -E -e "\@${COPYRIGHT_PREFIX}@s@(${COPYRIGHT_PREFIX} [12][0-9]{3}, )[12][0-9]{3}( ${COPYRIGHT_SUFFIX}.*)@\1${COPYRIGHT_YEAR}\2@" \
          -e "\@${COPYRIGHT_PREFIX}@s@(${COPYRIGHT_PREFIX} [12][0-9]{3})( ${COPYRIGHT_SUFFIX}.*)@\1, ${COPYRIGHT_YEAR}\2@" \
          -i '' ${1}
}

for i in `cat ${1} | cut -d ':' -f1 | sed s@'/pipeline/source/'@@g`
do
  echo "Updating $i"
  update_copyright "$i"
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment