diff options
author | Rob Mohr <mohrr@google.com> | 2023-02-09 18:38:36 +0000 |
---|---|---|
committer | CQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2023-02-09 18:38:36 +0000 |
commit | 09b23d4c891eda58dc241c55041e02323e6e5789 (patch) | |
tree | 22bc5c94a6e547ca5abcca9326d7a30b16065f9a /pw_presubmit | |
parent | af17bd705dfaa33d764f93995ab218647ab12f2f (diff) | |
download | pigweed-09b23d4c891eda58dc241c55041e02323e6e5789.tar.gz |
pw_cli: Process *_ROOT env vars as Path objects
Change-Id: I7f88065e996b8f7dbfee1f936d5d8a501e3f4d47
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/128615
Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com>
Reviewed-by: Alexei Frolov <frolv@google.com>
Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Diffstat (limited to 'pw_presubmit')
-rwxr-xr-x | pw_presubmit/py/pw_presubmit/format_code.py | 2 | ||||
-rw-r--r-- | pw_presubmit/py/pw_presubmit/keep_sorted.py | 18 | ||||
-rw-r--r-- | pw_presubmit/py/pw_presubmit/presubmit.py | 2 |
3 files changed, 12 insertions, 10 deletions
diff --git a/pw_presubmit/py/pw_presubmit/format_code.py b/pw_presubmit/py/pw_presubmit/format_code.py index ceaf64e21..03f1f3712 100755 --- a/pw_presubmit/py/pw_presubmit/format_code.py +++ b/pw_presubmit/py/pw_presubmit/format_code.py @@ -739,7 +739,7 @@ def format_paths_in_repo( # If this is a Git repo, list the original paths with git ls-files or diff. if repo: - project_root = Path(pw_cli.env.pigweed_environment().PW_PROJECT_ROOT) + project_root = pw_cli.env.pigweed_environment().PW_PROJECT_ROOT _LOG.info( 'Formatting %s', git_repo.describe_files( diff --git a/pw_presubmit/py/pw_presubmit/keep_sorted.py b/pw_presubmit/py/pw_presubmit/keep_sorted.py index 738b816a3..a1068f30c 100644 --- a/pw_presubmit/py/pw_presubmit/keep_sorted.py +++ b/pw_presubmit/py/pw_presubmit/keep_sorted.py @@ -446,7 +446,7 @@ def keep_sorted_in_repo( base = 'HEAD~1' # If this is a Git repo, list the original paths with git ls-files or diff. - project_root = Path(pw_cli.env.pigweed_environment().PW_PROJECT_ROOT) + project_root = pw_cli.env.pigweed_environment().PW_PROJECT_ROOT if repo: _LOG.info( 'Sorting %s', @@ -466,17 +466,19 @@ def keep_sorted_in_repo( ) return 1 - if not output_directory: - if repo: - output_directory = repo / DEFAULT_PATH - else: - output_directory = project_root / DEFAULT_PATH + outdir: Path + if output_directory: + outdir = output_directory + elif repo: + outdir = repo / DEFAULT_PATH + else: + outdir = project_root / DEFAULT_PATH ctx = KeepSortedContext( paths=files, fix=fix, - output_dir=output_directory, - failure_summary_log=output_directory / 'failure-summary.log', + output_dir=outdir, + failure_summary_log=outdir / 'failure-summary.log', ) errors = _process_files(ctx) diff --git a/pw_presubmit/py/pw_presubmit/presubmit.py b/pw_presubmit/py/pw_presubmit/presubmit.py index 113a5ed3f..4d3086838 100644 --- a/pw_presubmit/py/pw_presubmit/presubmit.py +++ b/pw_presubmit/py/pw_presubmit/presubmit.py @@ -484,7 +484,7 @@ class PresubmitContext: @staticmethod def create_for_testing(): parsed_env = pw_cli.env.pigweed_environment() - root = Path(parsed_env.PW_PROJECT_ROOT) + root = parsed_env.PW_PROJECT_ROOT presubmit_root = root / 'out' / 'presubmit' return PresubmitContext( root=root, |