LicenseHeaderStep with `git --follow` in some repositories produces garbage year history

Open
#774 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
git, java

Research direction

Start in lib/src/main/java/com/diffplug/spotless/generic/LicenseHeaderStep.java around lines 289-294 and inspect how git history is queried with --follow. Verify the behavior against the reported small functional-interface example, and consider the issue's proposed way to disable --follow so license-header years no longer include incorrect history.

Written by the indexing model from the issue text.

Description

enhancement
  • summary of problem

I have been working on migrating a project to use spotless for license headers. The project hasn't been great on keeping license headers up to date - so I used spotless's feature to allow fixing the header years from git history.

However with the project the --follow option for git produces a lot of garbage header years.
Examples being small functional interfaces created in 2020 resolving to get an incorrect year range of 2018, 2020.

Possible solution:
Allow disabling the --follow option for git history check here: https://github.com/diffplug/spotless/blob/a30553386acfa24f0d97f587249c38f44feb79b6/lib/src/main/java/com/diffplug/spotless/generic/LicenseHeaderStep.java#L289-L294

  • gradle or maven version
    Gradle 6.7.1

  • spotless version
    5.8.2

Dominant language
Java
Stars
5.7k
Forks
560
Avg merge
1d 13h
Merged PRs (30d)
43

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from diffplug/spotless

All issues in diffplug/spotless

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.