3

Suppose there is a large project not adhering to a specific python formatting standard, and you want to reformat all the python code using the python formatter black, and suppose the large scale project is pretty big (let's say ~2,000 python files), and ~30 people working on said project, each working on multiple features on multiple branches. Also there could be different semi-frozen "master" branches, that are occasionally merged with the newer code.

Using black on the entire code base would cause super conflicts with any open branch... How would you go about doing this process and minimizing conflicts?

JavaNoob
  • 31
  • 1
  • You seem to either need to apply black for all your branches, or use `-Xignore-all-space` while merging (and probably rebasing) in git if black only changes whitespaces ( https://stackoverflow.com/questions/9776527/merging-without-whitespace-conflicts ). – terrorrussia-keeps-killing Dec 15 '20 at 14:46
  • It adds trailing commas, and changes every occurrence of a ' to a ", which changes a LOT OF LINES. It also adds parenthesis whereever it likes. – JavaNoob Dec 15 '20 at 15:51
  • Create a test branch `A` off your "master"/"dev", apply black to (all) Python files and make a commit. After that create another test branch `B` off your biggest feature branch that has as many changes as possible (does not matter if the branch is in half-done state, but many changes are better for testing), apply black only to files that have changed within the feature branch, and make a separate commit once black is applied. Once it's done, switch to branch `A` and try `git merge B`. It should go seamlessly since both test branches share the same formatting policy right in the source code. – terrorrussia-keeps-killing Dec 15 '20 at 16:07
  • This isn't really on topic for stackoverflow - it's more a softwareengineering.stackexchange.com question. However, it's pretty typical to handle this with a [flag day](https://en.wikipedia.org/wiki/Flag_day_(computing)). This gives all subgroups a target date to shoot for. In the case of reformatting with black, that just means everyone has to have black, and the directives, available on their own machines. – torek Dec 15 '20 at 23:05

0 Answers0