aboutsummaryrefslogtreecommitdiff
path: root/pw_presubmit
diff options
context:
space:
mode:
authorRob Mohr <mohrr@google.com>2022-02-11 12:45:50 -0800
committerCQ Bot Account <pigweed-scoped@luci-project-accounts.iam.gserviceaccount.com>2022-02-11 21:18:48 +0000
commit0df11c1a0f6036323bc27afdf0cd5230c3a6c38d (patch)
treeddf8bb792598408a0c26e2f3f43c10d3099daa28 /pw_presubmit
parent9c0cf1de7226e628710a7230d8331fce97fa5185 (diff)
downloadpigweed-0df11c1a0f6036323bc27afdf0cd5230c3a6c38d.tar.gz
pw_presubmit: Show better submodule names
This changes lines like this: INF Checking all files in the src repo To this: INF Checking all files in the third_party/pigweed/src repo Change-Id: I79bf4b7a3aa5abd88aa68311b1b3db309d58564f Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/84121 Pigweed-Auto-Submit: Rob Mohr <mohrr@google.com> Reviewed-by: Wyatt Hepler <hepler@google.com> Commit-Queue: Auto-Submit <auto-submit@pigweed.google.com.iam.gserviceaccount.com>
Diffstat (limited to 'pw_presubmit')
-rwxr-xr-xpw_presubmit/py/pw_presubmit/format_code.py5
-rw-r--r--pw_presubmit/py/pw_presubmit/git_repo.py16
-rw-r--r--pw_presubmit/py/pw_presubmit/presubmit.py3
3 files changed, 18 insertions, 6 deletions
diff --git a/pw_presubmit/py/pw_presubmit/format_code.py b/pw_presubmit/py/pw_presubmit/format_code.py
index bce7b7055..623b5444d 100755
--- a/pw_presubmit/py/pw_presubmit/format_code.py
+++ b/pw_presubmit/py/pw_presubmit/format_code.py
@@ -41,6 +41,7 @@ except ImportError:
os.path.abspath(__file__))))
import pw_presubmit
+import pw_cli.env
from pw_presubmit import cli, git_repo
from pw_presubmit.tools import exclude_paths, file_summary, log_run, plural
@@ -433,9 +434,11 @@ def format_paths_in_repo(paths: Collection[Union[Path, str]],
# 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)
_LOG.info(
'Formatting %s',
- git_repo.describe_files(repo, Path.cwd(), base, paths, exclude))
+ git_repo.describe_files(repo, Path.cwd(), base, paths, exclude,
+ project_root))
# Add files from Git and remove duplicates.
files = sorted(
diff --git a/pw_presubmit/py/pw_presubmit/git_repo.py b/pw_presubmit/py/pw_presubmit/git_repo.py
index e1afff892..25b3afa86 100644
--- a/pw_presubmit/py/pw_presubmit/git_repo.py
+++ b/pw_presubmit/py/pw_presubmit/git_repo.py
@@ -178,16 +178,24 @@ def _describe_constraints(git_root: Path, repo_path: Path,
', '.join(p.pattern for p in exclude) + ')')
-def describe_files(git_root: Path, repo_path: Path, commit: Optional[str],
+def describe_files(git_root: Path,
+ repo_path: Path,
+ commit: Optional[str],
pathspecs: Collection[PathOrStr],
- exclude: Collection[Pattern]) -> str:
+ exclude: Collection[Pattern],
+ project_root: Path = None) -> str:
"""Completes 'Doing something to ...' for a set of files in a Git repo."""
constraints = list(
_describe_constraints(git_root, repo_path, commit, pathspecs, exclude))
+
+ name = git_root.name
+ if project_root and project_root != git_root:
+ name = str(git_root.relative_to(project_root))
+
if not constraints:
- return f'all files in the {git_root.name} repo'
+ return f'all files in the {name} repo'
- msg = f'files in the {git_root.name} repo'
+ msg = f'files in the {name} repo'
if len(constraints) == 1:
return f'{msg} {constraints[0]}'
diff --git a/pw_presubmit/py/pw_presubmit/presubmit.py b/pw_presubmit/py/pw_presubmit/presubmit.py
index 599ef1736..08585d04e 100644
--- a/pw_presubmit/py/pw_presubmit/presubmit.py
+++ b/pw_presubmit/py/pw_presubmit/presubmit.py
@@ -444,7 +444,8 @@ def run(program: Sequence[Callable],
_LOG.info(
'Checking %s',
- git_repo.describe_files(repo, repo, base, pathspecs, exclude))
+ git_repo.describe_files(repo, repo, base, pathspecs, exclude,
+ root))
if output_directory is None:
output_directory = root / '.presubmit'