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 6
6
7
7
def run_clang_format (args ) -> int :
8
8
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' ]
11
10
else :
12
- dry_run_cmd = ['clang-format' , '-dry-run' , '--Werror' ]
13
- edit_cmd = ["clang-format" , '-i' ]
11
+ command = ["clang-format" , '-i' ]
14
12
for arg in args :
15
13
if arg == expect_version or arg .startswith ("--version" ):
16
14
continue
17
- dry_run_cmd .append (arg )
18
- edit_cmd .append (arg )
15
+ command .append (arg )
19
16
20
- retval = 0
21
17
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 )
27
23
return retval , output
28
24
except FileNotFoundError as e :
29
- return 1 , e
25
+ retval = 1
26
+ return retval , e
30
27
31
28
32
29
def main () -> int :
Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ def run_clang_tidy(args) -> int:
19
19
output = sp .stdout .decode ("utf-8" )
20
20
return retval , output
21
21
except FileNotFoundError as e :
22
- return 1 , e
22
+ retval = 1
23
+ return retval , e
23
24
24
25
25
26
def main () -> int :
You can’t perform that action at this time.
0 commit comments