Skip to content
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

License replacement attempts to preserve existing year info #1227

Merged
merged 7 commits into from
Feb 10, 2020

Conversation

iamdanfox
Copy link
Contributor

@iamdanfox iamdanfox commented Feb 10, 2020

Before this PR

@tusharnarayan got a PR to upgrade baseline on his project and it nuked all his existing license (which were pretty bonkers anyway) and replaced them with 2020 ones. This upsets legal, who prefer to preserve the original creation date of files where possible.

After this PR

==COMMIT_MSG==
Auto-fixing license headers will attempt to preserve the existing year of creation.
==COMMIT_MSG==

I predict this will be incredibly useful when we want to open source an internal project, because we should be able to just swap out the license template it .baseline/copyright and then run ./gradlew format.

Confirming I ran this on tushar's project and it did the right thing.

Possible downsides?

  • we diverge further from spotless' existing LicenseHeaderStep

@changelog-app
Copy link

changelog-app bot commented Feb 10, 2020

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Auto-fixing license headers will attempt to preserve the existing year of creation.

Check the box to generate changelog(s)

  • Generate changelog entry

boolean existingHeaderContainsYear = yearInfo.find();
String year = existingHeaderContainsYear
? yearInfo.group(0)
: String.valueOf(YearMonth.now().getYear());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this line is really the money.

the rest of the PR is mainly just me deleting indirection that doesn't seem necessary now that we're not working around spotless' API

@bulldozer-bot bulldozer-bot bot merged commit fc55057 into develop Feb 10, 2020
@bulldozer-bot bulldozer-bot bot deleted the dfox/license branch February 10, 2020 23:44
@svc-autorelease
Copy link
Collaborator

Released 3.4.1

@ferozco
Copy link
Contributor

ferozco commented Feb 10, 2020

Thanks @iamdanfox!

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

Successfully merging this pull request may close these issues.

3 participants