diff options
| author | Victor Pushkarev <corvinus.v@gmail.com> | 2026-09-15 16:07:01 +0300 |
|---|---|---|
| committer | gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2026-09-16 04:54:02 -0700 |
| commit | c638b54e19f4765904613f729b2c9059fc4799d2 (patch) | |
| tree | 6f702cd0b4db264a8c1042d6a4e8d14f7a55f18e /command.py | |
| parent | fb4a91060ea34a939bb5ab6ffc494d1aa25e1979 (diff) | |
| download | git-repo-c638b54e19f4765904613f729b2c9059fc4799d2.tar.gz | |
command: preserve project filters in regex selection
`FindProjects` gets its candidate projects from `GetProjects` and then
applies regex matching. However, it only forwards `all_manifests`, so
other project filters are lost on regex paths.
As a result, `repo forall -r/-i --groups` falls back to the configured
group selection instead of using the requested groups.
Similarly, `repo list -r --groups` ignores the requested groups, and
`repo list -r --all` still excludes projects without a checkout.
Pass `groups` and `missing_ok` through `FindProjects`, and forward the
existing options from `forall` and `list`. When no group override is
given, keep using each manifest's effective groups.
Add regression tests for `FindProjects` and both command paths.
Change-Id: I5dfc22172fdd81de5312a84433867300a1342aec
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/631281
Reviewed-by: Mike Frysinger <vapier@google.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Victor Pushkarev <corvinus.v@gmail.com>
Tested-by: Victor Pushkarev <corvinus.v@gmail.com>
Diffstat (limited to 'command.py')
| -rw-r--r-- | command.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/command.py b/command.py index 6aa0ca86b..7f60834ad 100644 --- a/command.py +++ b/command.py | |||
| @@ -545,7 +545,14 @@ class Command: | |||
| 545 | result.sort(key=_getpath) | 545 | result.sort(key=_getpath) |
| 546 | return result | 546 | return result |
| 547 | 547 | ||
| 548 | def FindProjects(self, args, inverse=False, all_manifests=False): | 548 | def FindProjects( |
| 549 | self, | ||
| 550 | args: List[str], | ||
| 551 | inverse: bool = False, | ||
| 552 | all_manifests: bool = False, | ||
| 553 | groups: Optional[str] = "", | ||
| 554 | missing_ok: Optional[bool] = False, | ||
| 555 | ) -> List["Project"]: | ||
| 549 | """Find projects from command line arguments. | 556 | """Find projects from command line arguments. |
| 550 | 557 | ||
| 551 | Args: | 558 | Args: |
| @@ -555,10 +562,18 @@ class Command: | |||
| 555 | all_manifests: a boolean, if True then all manifests and | 562 | all_manifests: a boolean, if True then all manifests and |
| 556 | submanifests are used. If False, then only the local | 563 | submanifests are used. If False, then only the local |
| 557 | (sub)manifest is used. | 564 | (sub)manifest is used. |
| 565 | groups: a string specifying manifest groups. If empty or None, use | ||
| 566 | each manifest's effective groups. | ||
| 567 | missing_ok: a boolean, whether to allow missing projects. | ||
| 558 | """ | 568 | """ |
| 559 | result = [] | 569 | result = [] |
| 560 | patterns = [re.compile(r"%s" % a, re.IGNORECASE) for a in args] | 570 | patterns = [re.compile(r"%s" % a, re.IGNORECASE) for a in args] |
| 561 | for project in self.GetProjects("", all_manifests=all_manifests): | 571 | for project in self.GetProjects( |
| 572 | "", | ||
| 573 | groups=groups, | ||
| 574 | missing_ok=missing_ok, | ||
| 575 | all_manifests=all_manifests, | ||
| 576 | ): | ||
| 562 | paths = [project.name, project.RelPath(local=not all_manifests)] | 577 | paths = [project.name, project.RelPath(local=not all_manifests)] |
| 563 | for pattern in patterns: | 578 | for pattern in patterns: |
| 564 | match = any(pattern.search(x) for x in paths) | 579 | match = any(pattern.search(x) for x in paths) |
