|
41 | 41 | GITHUB_EVENT_NAME = os.getenv("GITHUB_EVENT_NAME", "unknown")
|
42 | 42 | RUNNER_WORKSPACE = os.getenv("RUNNER_WORKSPACE", "")
|
43 | 43 |
|
| 44 | +IS_ON_WINDOWS = sys.platform.startswith("win32") |
| 45 | + |
44 | 46 | # setup CLI args
|
45 | 47 | cli_arg_parser = argparse.ArgumentParser(
|
46 | 48 | description=__doc__[: __doc__.find("If executed from")]
|
@@ -407,9 +409,11 @@ def run_clang_tidy(
|
407 | 409 | "clang-tidy" + ("" if not version else f"-{version}"),
|
408 | 410 | "--export-fixes=clang_tidy_output.yml",
|
409 | 411 | ]
|
410 |
| - if sys.platform.startswith("win32") and os.path.exists(version + os.sep + "bin"): |
411 |
| - cmds[0] = f"{version + os.sep}bin\\clang-tidy.exe" |
412 |
| - elif not sys.platform.startswith("win32") and not version.isdigit(): |
| 412 | + if IS_ON_WINDOWS: |
| 413 | + cmds[0] = "clang-tidy" |
| 414 | + if os.path.exists(version + "\\bin"): |
| 415 | + cmds[0] = f"{version}\\bin\\clang-tidy.exe" |
| 416 | + elif not version.isdigit(): |
413 | 417 | logger.warning("ignoring invalid version number %s.", version)
|
414 | 418 | cmds[0] = "clang-tidy"
|
415 | 419 | if checks:
|
@@ -456,15 +460,16 @@ def run_clang_format(
|
456 | 460 | lines_changed_only: A flag that forces focus on only changes in the event's
|
457 | 461 | diff info.
|
458 | 462 | """
|
459 |
| - is_on_windows = sys.platform.startswith("win32") |
460 | 463 | cmds = [
|
461 | 464 | "clang-format" + ("" if not version else f"-{version}"),
|
462 | 465 | f"-style={style}",
|
463 | 466 | "--output-replacements-xml",
|
464 | 467 | ]
|
465 |
| - if is_on_windows and os.path.exists(version + os.sep + "bin"): |
466 |
| - cmds[0] = f"{version}\\bin\\clang-format.exe" |
467 |
| - elif not is_on_windows and not version.isdigit(): |
| 468 | + if IS_ON_WINDOWS: |
| 469 | + cmds[0] = "clang-format" |
| 470 | + if os.path.exists(version + "\\bin"): |
| 471 | + cmds[0] = f"{version}\\bin\\clang-format.exe" |
| 472 | + elif not version.isdigit(): |
468 | 473 | logger.warning("ignoring invalid version number %s.", version)
|
469 | 474 | cmds[0] = "clang-format"
|
470 | 475 | if lines_changed_only:
|
|
0 commit comments