Prettier Version 2 (and how to deal with large merge conflicts it may cause) #6517
tephenavies
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
TerriaJS and TerriaMap have been using Prettier to automate code formatting since 2019 which helps us focus on writing code while Prettier takes on code formatting for us. This week we've upgraded our Prettier version to 2.7.1 and at the same time applied code formatting to many more files within the terriajs and TerriaMap repositories. This may lead to large merge conflicts the next time you merge from
main
if you have made changes in your fork to code that has now been reformatted. Follow the steps below to resolve these merge conflicts:git checkout -b whatever-merge
.yarn install
.git merge pre-prettier-v2
. Resolve any conflicts as usual.yarn install
again (this step will help resolve conflicts inyarn.lock
, and it's also needed to upgrade prettier to v2)git commit --no-verify
).git merge post-prettier-v2 --strategy=ours --no-commit
yarn prettier
git commit -a
.git merge origin/main
(replaceorigin
with correct remote). Resolve any conflicts as normal.If you're merging a branch-that-has-already-followed-this-procedure into your branch, you can follow the procedure above except that you need to use different commits instead of
pre-prettier-v2
andpost-prettier-v2
. Look at the commits in the source branch and you should see two that look like this:Use the commit hash of the commit that merged
pre-prettier-v2
in place ofpre-prettier-v2
above. Use the commit hash of the commit that mergedpost-prettier-v2
in place ofpost-prettier-v2
above.These instructions will work for a fork of TerriaMap or a fork of terriajs as we've used the same process and tag names in both.
Having trouble? Post a comment below.
Beta Was this translation helpful? Give feedback.
All reactions