-
-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support injecting Copyright Years based on file existence #240
Support injecting Copyright Years based on file existence #240
Conversation
For some Copyright policies the years in the header should reflect only the existence of that file not the project as a whole. While this can be achieved by using ${license.git.copyrightCreationYear} and ${license.git.copyrightLastYear} in the header template you end up generating awkward headers for some files e.g. 2021-2021. And you cannot use ${license.git.copyrightYears} for this use case because that will use the project inception year giving you something like 2019-2021. This commit adds a new calculated property ${license.git.copyrightExistenceYears} which provides this information and may be used in header templates where this behaviour is desired. It also fixes a bug in GitLookup whereby if you had modified the file it would incorrectly calculate the year range (because the creation year was always defaulted to current year for modified files) and falsely flag a license header as missing (or reformat unncessarily).
Sorry for the delay, I will merge and issue a 4.2.rc2. |
@mathieucarbou No worries, thanks for accepting this PR 👍 |
@mathieucarbou No great rush on my end |
I just discovered this new feature and I'd like to implement it. Any chance of rc2 soon-ish? I tried using SNAPSHOT but it appears only the metadata is there and no actual release files. |
Yes it's planned next week 😊 |
I'm running into an odd issue with this plugin. It's rewriting all headers and removing the earlier year, but only on OpenBSD. For a sample file:
Changes the file thus:
This of course modifies the file so running it again turns it all into 2021-2022 on the next pass... Should I create a new issue? Anything else I can help test/debug? Some configuration I'm missing? |
Ah, figured it out. On that VM I had a shallow clone so the year determination was only going back a few hundred commits. So, the follow on question: would it be possible for the plugin to detect the presence of a shallow clone and not rewrite if that is the case? |
For some Copyright policies the years in the header should reflect only
the existence of that file not the project as a whole. While this can
be achieved by using
${license.git.copyrightCreationYear}
and${license.git.copyrightLastYear}
in the header template you end upgenerating awkward headers for some files e.g.
2021-2021
. And youcannot use
${license.git.copyrightYears}
for this use case because thatwill use the project inception year giving you something like
2019-2021
.This commit adds a new calculated property
${license.git.copyrightExistenceYears}
which provides this informationand may be used in header templates where this behaviour is desired. This
should basically address the issue described in adobe/S3Mock#241
It also fixes a bug in
GitLookup
whereby if you had modified the fileit would incorrectly calculate the year range (because the creation year
was always defaulted to current year for modified files) and falsely flag
a license header as missing (or reformat unncessarily).