Skip to content

Commit 68d618f

Browse files
[clang-format] Add ability for clang-format-diff to exit with non-0 status (#70883)
This patch adds the ability for the clang-format-diff script to exit with a non-zero status if it detects that formatting changes are necessary. This makes it easier to use clang-format-diff as part of a DevOps pipeline, since you could add a stage to run clang-format-diff and fail if the formatting needs to be fixed.
1 parent d36eb79 commit 68d618f

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

clang/tools/clang-format/clang-format-diff.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,7 @@ def main():
185185
diff_string = "".join(diff)
186186
if len(diff_string) > 0:
187187
sys.stdout.write(diff_string)
188+
sys.exit(1)
188189

189190

190191
if __name__ == "__main__":

0 commit comments

Comments
 (0)