psf / black

The uncompromising Python code formatter
https://black.readthedocs.io/en/stable/
MIT License
38.31k stars 2.42k forks source link

provide a git merge driver #896

Open graingert opened 5 years ago

graingert commented 5 years ago

Provide a merge driver tool similar to clang_format_merge_driver to allow easier merge conflict resolution when merging non-blackened branches into a blackened branch

https://chromium.googlesource.com/chromium/tools/depot_tools.git/+/refs/heads/master/clang_format_merge_driver.py

max-sixty commented 5 years ago

Does anyone have any advice for projects that are rolling this out, specifically to make it easy for existing PRs to merge? We're planning on rolling this out in xarray and looking to ease the transition.

Off the top of my head I'm thinking we can ask existing PRs to:

zsol commented 5 years ago

I generally recommend the second approach (apply black to the PR before merging), it works well

max-sixty commented 5 years ago

I had meant those as a list of steps, rather than options. My experience is that only running black on a feature branch creates a bunch of conflicts on merging in a master with black previously applied. I just attempted on a test feature branch, and it did create conflicts. I think that makes sense - both parents have changes over the lines of the feature branch (assuming the feature branch has edits to existing lines).

Am I missing something?