File tree Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Original file line number Diff line number Diff line change 66
77def run_clang_format (args ) -> int :
88 if expect_version :
9- dry_run_cmd = [f'clang-format-{ expect_version } ' , '-dry-run' , '--Werror' ]
10- edit_cmd = [f'clang-format-{ expect_version } ' , '-i' ]
9+ command = [f'clang-format-{ expect_version } ' , '-i' ]
1110 else :
12- dry_run_cmd = ['clang-format' , '-dry-run' , '--Werror' ]
13- edit_cmd = ["clang-format" , '-i' ]
11+ command = ["clang-format" , '-i' ]
1412 for arg in args :
1513 if arg == expect_version or arg .startswith ("--version" ):
1614 continue
17- dry_run_cmd .append (arg )
18- edit_cmd .append (arg )
15+ command .append (arg )
1916
20- retval = 0
2117 try :
22- sp = subprocess . run ( dry_run_cmd , stdout = subprocess . PIPE )
23- retval = sp . returncode
24- output = sp . stdout . decode ( "utf-8" )
25- if retval != 0 :
26- subprocess .run (edit_cmd , stdout = subprocess .PIPE )
18+ if "--dry- run" in command :
19+ sp = subprocess . run ( command , stdout = subprocess . PIPE )
20+ retval = - 1 # Not a fail just identify it's a dry-run.
21+ output = sp . stdout . decode ( "utf-8" )
22+ retval = subprocess .run (command , stdout = subprocess .PIPE )
2723 return retval , output
2824 except FileNotFoundError as e :
29- return 1 , e
25+ retval = 1
26+ return retval , e
3027
3128
3229def main () -> int :
Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ def run_clang_tidy(args) -> int:
1919 output = sp .stdout .decode ("utf-8" )
2020 return retval , output
2121 except FileNotFoundError as e :
22- return 1 , e
22+ retval = 1
23+ return retval , e
2324
2425
2526def main () -> int :
You can’t perform that action at this time.
0 commit comments