Skip to content

Commit

Permalink
[clang-format] Add ability for clang-format-diff to exit with non-0 s…
Browse files Browse the repository at this point in the history
…tatus (#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.
  • Loading branch information
conrad-donahue committed Nov 9, 2023
1 parent d36eb79 commit 68d618f
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions clang/tools/clang-format/clang-format-diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ def main():
diff_string = "".join(diff)
if len(diff_string) > 0:
sys.stdout.write(diff_string)
sys.exit(1)


if __name__ == "__main__":
Expand Down

0 comments on commit 68d618f

Please sign in to comment.