For many new contributors, we need to ask them to format their patch so that it matches the existing style. Even with recurring contributors, it is easy to forget reformatting after rebasing/making changes etc and fixing it is mostly a tedious affair.
I don't have much experience with CI stuff but I imagine it could be something where:
- If we have high trust in the formatter: before your code gets merged, the commits are reformatted and then merged. I've seen this in practice before. This totally skips discussion around formatting altogether. This also avoids the "ugh, my PR failed because it's formatted wrong ".
- If we have low-medium trust in the formatter: have the formatter add extra fixup! commits in PR that fix the formatting which can be looked at, and then automation takes care of rebasing the fixup! commits properly when the PR is "merged".
I'm sure there are probably a dozen ways to do this, IDK what the best one is.
How difficult would it be to set up automation for formatting? Are there good reasons to not implement something like this?
I saw previous posts: Policy on the use of clang-format and Using git-clang-format in the Swift compiler code base. but I'm not sure what to make of it.
(To be clear: I'm not trying to discuss what style or exact clang-format options should be used. The question is about having automation do it for us.)