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 header forces same year for all source files #183

Closed
chrisbanes opened this issue Jan 2, 2018 · 7 comments
Closed

License header forces same year for all source files #183

chrisbanes opened this issue Jan 2, 2018 · 7 comments

Comments

@chrisbanes
Copy link

My IDE correctly auto generated a new copyright header with the year 2018, whereas my spotless license header still has 2017. If I change my spotless file to 2018, all other source files have 2018 applied which isn't what I want.

Any ideas? This might be working as intended, but it would be nice if either:
a) Spotless exposes common embed tags similar to IntelliJ (year, author, etc)

b) We can embed regex (for check) with a default value (for apply) in the header. Maybe something like:
Copyright blah $([0-9]{4}, 2018)

@jbduncan
Copy link
Member

jbduncan commented Jan 2, 2018

Hi @chrisbanes. I'm not sure if I've understood you correctly. Am I correct in thinking that you're saying that your IDE updates copyright headers to 2018, as you expected, and that Spotless updates copyright headers to 2018 as well once you change the file pointed to by licenseHeaderFile to itself have the year 2018 instead of 2017, but that this is contrary to what you expected?

@chrisbanes
Copy link
Author

chrisbanes commented Jan 2, 2018

Kind of. My IDE generates new source files with a copyright header of 2018, which I expect. Existing files are kept the same (2017, etc).

I don't see a way to support that with Spotless (but maybe I'm wrong).

@jbduncan
Copy link
Member

jbduncan commented Jan 2, 2018

Okay, I think I understand better what you're after now.

Regarding common embed tags for year, author, etc., there is coincidentally an open PR to introduce an embed-tag feature for years specifically. By my understanding, it would allow embedding an optional "$YEAR" tag into the template header pointed to by licenseHeaderFile, and then Spotless would automatically replace all instances of "$YEAR" in the template with the current year in the generated in-source-file headers.

However, I suspect that that's not exactly what you're after, since this PR would only support updating all copyright headers throughout a codebase with the current year, instead of just putting the current year into the copyright headers of new files.

I admit that it's not clear to me personally if or how we could support a feature like this. @nedtwigg @baptistemesta do you have any thoughts on this?

@chrisbanes
Copy link
Author

Aha! I missed that PR. It actually looks @baptistemesta had the same idea and combined A & B above. Feel free to close this.

@jbduncan
Copy link
Member

jbduncan commented Jan 2, 2018

Cool, I'll close this issue then. Feel free to re-open if more needs to be discussed. :)

@jbduncan jbduncan closed this as completed Jan 2, 2018
@nedtwigg
Copy link
Member

nedtwigg commented Jan 3, 2018

@baptistemesta's PR has been merged and released in 3.8.0. You might want to also take a look at #178.

@nedtwigg
Copy link
Member

nedtwigg commented Jun 5, 2020

We now support changing the year only for changed files (also a big performance improvement) using our new ratchetFrom 'origin/master' feature.

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

No branches or pull requests

3 participants