If formatting fails in CI, print detailed diff #5756
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #5666.
Aren't you tired when, for whatever reason, your local clang-format does format files a bit differently than it gets formatted in the CI, so CI fails on you, and you have to find creative ways to guess what that format might be, and, for example, spin up an Ubuntu machine, and run clang-format there? I am not saying we should not eventually find the root cause and eliminate possibilities for formatting discrepancies, if possible; but until then this fix will save you time.
I have tested this fix in the CodeGen repo (log: https://dev.azure.com/azure-sdk/internal/_build/results?buildId=3924247&view=logs&j=b5cdfb1e-c180-561f-918e-a169e451719e&t=a95f8d37-03f1-5b78-3f33-b1433acf4822), and when clang-format starts giving me troubles in the CI, I now I can have a follow-up commit with the right formatting basically within seconds. All I do, is I copy the part of the log file between
---s, put it inc:\src\patch.txt(not forgetting to put empty line at the end ofpatch.txt), then I go toc:\src\azure-sdk-for-cpp, rungit apply --ignore-space-change ..\patch.txt, add files to commit, review changes, and push them to my PR.