10/07/2019, 12:46 PM
Hi all, I’m repeating myself from the pants-devel mailing list and the commit message, but I thought it would be better to over-advertise this rather than under-advertise it: The PR that formats our python code with Black ( was merged this morning (London time). It means that if you have an ongoing branch that predates that PR, you will need to do a little dance to avoid having to manually resolve formatting related conflicts next time you pull master. Here are some steps you may follow that should make the process automatic:
Copy code
# Checkout your feature branch
git checkout feature_branch

# The pre-commit check can be a little annoying when doing rebases (can't pass --no-verify).
# Let's manually disable it for the time of our rebases
mv ./.git/hooks/pre-commit ./.git/hooks/pre-commit.backup

# Manually handle any (genuine) conflict pre_black
git rebase black-formatting^

# Automatically format the code in each commit of your feature branch
git rebase --interactive --exec './pants --owner-of="`git show --name-only --pretty=\"\" HEAD`" fmt-v2 && git add `git show --name-only --pretty="" HEAD` && git commit --amend --no-edit && git stash' black-formatting^

# Rebase your formatted code on top of the black commit.
# Because of the previous step, and because the black commit only formats files,
# This should not cause any conflict.
# (Caveat: if you touched the isort config or one of the tests that were formatting dependent,
# you may have a small amount of conflicts to handle)
git rebase --interactive --strategy-option=theirs --exec './pants --changed-parent="HEAD^" fmt-v2 && git add `git show --name-only --pretty="" HEAD` && git commit --amend --no-edit' black-formatting

# Handle any conflict since black (only genuine conflicts. formatting won't be part of it)
git rebase master

# Don't forget to re-enable the pre-commit hook
mv ./.git/hooks/pre-commit.backup ./.git/hooks/pre-commit

# All done. When you're ready, you may update your PR.
git push -f your_remote feature_branch
If you have any difficulty with the above steps, or are unsure about anything; feel free to DM me and I will help you through it 😄 Thanks everyone for the discussions, reviews and comments that made this possible 🙂
👌 1
👖 1
❤️ 1


10/07/2019, 5:22 PM
i had to run
git fetch --tags upstream
to get the
❤️ 1
also shell backticks should be deprecated in favor of
❤️ 1
getting this when attempting to run the automatic rebase:
Copy code
/Users/dmcclanahan/tools/pants-v6/build-support/virtualenv: line 12: /Users/dmcclanahan/tools/pants-v6/build-support/build-support/ No such file or directory
i don't know what to do here, not sure why
is repeated here
going to
git clean -xfd
i guess
yeah ok this is still happening, will have to figure it out later


10/07/2019, 5:34 PM
Definitely some weirdness here