Skip to content

Add the ability to populate header years from git history.#604

Merged
nedtwigg merged 4 commits intomasterfrom
feat/license-header-retroactive
Jun 5, 2020
Merged

Add the ability to populate header years from git history.#604
nedtwigg merged 4 commits intomasterfrom
feat/license-header-retroactive

Conversation

@nedtwigg
Copy link
Copy Markdown
Member

@nedtwigg nedtwigg commented Jun 5, 2020

If you've setup a license header with $YEAR, you can do gradlew spotlessApply -P spotlessSetLicenseHeaderYearsFromGitHistory=true, and it will change every license header to match the output of:

  • oldest year: git log --follow --diff-filter=A --find-renames=40%
  • newest year: git log --max-count=1

@nedtwigg
Copy link
Copy Markdown
Member Author

nedtwigg commented Jun 5, 2020

It generates too much diff noise for a project with ongoing PRs such as this one, but as an example, this is the effect of running the command on this repository: dd279c3

You could adopt this slowly over time with ratchetFrom 'origin/master', but it is so slow and it disables up-to-date checking, so it's really only good for "format-the-world" cases. It took 1m 6s to run on this repository on my 2018 Macbook Pro (quad core 16GB RAM). Running on a larger project (~3k files with ~10 years of history) took 10m on a quad-core i7-7700HQ (VR-spec rig from 2017). But very useful for quickly getting an internal project ready to opensource with accurate header info.

@nedtwigg nedtwigg merged commit b9c1eab into master Jun 5, 2020
@nedtwigg nedtwigg deleted the feat/license-header-retroactive branch June 5, 2020 22:04
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

Successfully merging this pull request may close these issues.

1 participant