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

ratchetFrom 'origin/main' is confusing when 'origin/main' moves #627

Closed
nedtwigg opened this issue Jun 29, 2020 · 1 comment · Fixed by #631
Closed

ratchetFrom 'origin/main' is confusing when 'origin/main' moves #627

nedtwigg opened this issue Jun 29, 2020 · 1 comment · Fixed by #631
Labels

Comments

@nedtwigg
Copy link
Member

The setup:

  • you have a repo with two files, mine.txt and untouched.txt
  • you have configured them with ratchetFrom 'origin/main'
  • you are using licenseHeader '(C) $YEAR'
  • all files have (C) 2019, but today's year is now 2020

So far so good:

  • you start a feature branch off of main
  • you change mine.txt
  • you run spotlessApply which changes the copyright header on mine.txt from 2019 to 2020, but leaves untouched.txt alone since you have not changed it
  • for your local branch, spotlessCheck is passing

The problem:

  • the team merges some PR's to origin/main which change untouched.txt
  • you do a git fetch 'origin/main'
  • all of a sudden, spotlessCheck will fail for your local branch, even though you didn't make any changes
  • if you run spotlessApply, it will update the copyright header on untouched.txt from 2019 to 2020
  • now you have a merge conflict, and diff noise in your PR

Workarounds:

  • instead of using ratchetFrom 'origin/master', do ratchetFrom 'immutable-tag-like-v1.0.0'
  • OR, if Spotless is forcing you to change files you haven't changed, do git merge origin/main, so that you aren't duplicating changes

Solution:

  • For mutable branches like origin/master, Spotless should look for the merge-base, not just a naive-diff between origin/master and the WC.
@nedtwigg
Copy link
Member Author

nedtwigg commented Jul 2, 2020

Released in plugin-maven 2.0.0 and plugin-gradle 4.5.0.

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

Successfully merging a pull request may close this issue.

1 participant