Closed
Description
The setup:
- you have a repo with two files,
mine.txt
anduntouched.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 now2020
So far so good:
- you start a feature branch off of
main
- you change
mine.txt
- you run
spotlessApply
which changes the copyright header onmine.txt
from2019
to2020
, but leavesuntouched.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 changeuntouched.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 onuntouched.txt
from 2019 to 2020 - now you have a merge conflict, and diff noise in your PR
Workarounds:
- instead of using
ratchetFrom 'origin/master'
, doratchetFrom '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 betweenorigin/master
and the WC.