Browse Source
Historically, we have used `<introduction year>-<modification year>` as
the pattern for copyright headers.
For example: `Copyright 2002-2025 the original author or authors.`
However, we have been encouraged to use `present` as the modification
year.
In light of that, this commit updates the following to enforce the new
pattern.
- The patterns in our SpringHeaderCheck Checkstyle rules
- The `Copyright 2002-${year}` template in org.eclipse.jdt.ui.prefs
- The update_copyright_headers.sh script
See gh-35070
pull/35086/head
4 changed files with 11 additions and 16 deletions
File diff suppressed because one or more lines are too long
@ -1,21 +1,16 @@
@@ -1,21 +1,16 @@
|
||||
#!/bin/sh |
||||
# |
||||
# This shell script updates the copyright headers in source code files |
||||
# in the current branch that have been added or modified during the |
||||
# current year (at least as much as the `git diff` command supports the |
||||
# date range in terms of log history). |
||||
# in the current branch so that the headers conform to the pattern: |
||||
# <start-year>-present. |
||||
# |
||||
# For example, "Copyright 2002-2025" will be replaced with |
||||
# "Copyright 2002-current". |
||||
# |
||||
# This has only been tested on mac OS. |
||||
|
||||
current_year=$(date +'%Y') |
||||
echo Updating copyright headers in Java, Kotlin, and Groovy source code for year $current_year |
||||
echo Updating copyright headers in Java, Kotlin, and Groovy source code |
||||
|
||||
# Added/Modified this year and committed |
||||
for file in $(git --no-pager diff --name-only --diff-filter=AM @{$current_year-01-01}..@{$current_year-12-31} | egrep "^.+\.(java|kt|groovy)$" | uniq); do |
||||
sed -i '' -E "s/Copyright 2002-[0-9]{4}/Copyright 2002-$current_year/g" $file; |
||||
done |
||||
|
||||
# Added/Modified and staged but not yet committed |
||||
for file in $(git --no-pager diff --name-only --diff-filter=AM --cached | egrep "^.+\.(java|kt|groovy)$" | uniq); do |
||||
sed -i '' -E "s/Copyright 2002-[0-9]{4}/Copyright 2002-$current_year/g" $file; |
||||
for file in $(find -E . -type f -regex '.+\.(java|kt|groovy)$' | uniq); do |
||||
sed -i '' -E "s/Copyright ([0-9]{4})-[0-9]{4}/Copyright \1-present/g" $file; |
||||
done |
||||
|
||||
Loading…
Reference in new issue