Skip to content

Commit

Permalink
Rename some things to 'group-filter' from 'groups'
Browse files Browse the repository at this point in the history
As a result of review of the project groups feature documentation,
change some of the names to be more clear, and be a bit more forgiving
in the error handling.

A project's 'groups' list remains the same. No changes there.

However, we make the following changes:

- 'manifest: groups:' is now 'manifest: group-filter:'
- we add a west.manifest.Manifest.group_filter value, exposing
  'manifest: group-filter:' after validation and string conversion
- the config option 'manifest.groups' is now 'manifest.group-filter'
- invalid values in manifest.group-filter are downgraded to warnings
- the west update '--groups' option becomes '--group-filter', with
  a slightly shorter name '--gf' if you can't handle that

Signed-off-by: Martí Bolívar <[email protected]>
  • Loading branch information
mbolivar-nordic committed Jan 27, 2021
1 parent fa7bba2 commit 06ed61f
Show file tree
Hide file tree
Showing 5 changed files with 214 additions and 158 deletions.
46 changes: 24 additions & 22 deletions src/west/app/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 26,7 @@
from west.manifest import ImportFlag, Manifest, MANIFEST_PROJECT_INDEX, \
ManifestProject, _manifest_content_at, ManifestImportFailed, \
_ManifestImportDepth, ManifestVersionError, MalformedManifest
from west.manifest import is_group as is_manifest_group
from west.manifest import is_group as is_project_group
from west.manifest import MANIFEST_REV_BRANCH as MANIFEST_REV
from west.manifest import QUAL_MANIFEST_REV_BRANCH as QUAL_MANIFEST_REV
from west.manifest import QUAL_REFS_WEST as QUAL_REFS
Expand Down Expand Up @@ -719,9 719,11 @@ def do_add_parser(self, parser_adder):

group = parser.add_argument_group(
title='advanced options')
group.add_argument('-g', '--groups', action='append', default=[],
help='''proceed as if GROUPS was appended to
manifest.groups; may be given multiple times''')
group.add_argument('--group-filter', '--gf', action='append',
default=[], metavar='FILTER', dest='group_filter',
help='''proceed as if FILTER was appended to
manifest.group-filter; may be given multiple
times''')

group = parser.add_argument_group('deprecated options')
group.add_argument('-x', '--exclude-west', action='store_true',
Expand All @@ -741,24 743,24 @@ def do_run(self, args, user_args):
if args.exclude_west:
log.wrn('ignoring --exclude-west')

self.extra_groups = []
self.group_filter: List[str] = []

def handle(group):
group = group.strip()
if not group.startswith(('-', ' ')):
log.die(f'invalid --groups item {group}: '
def handle(group_filter_item):
item = group_filter_item.strip()
if not item.startswith(('-', ' ')):
log.die(f'invalid --group-filter item {item}: '
'must start with - or ')
if not is_manifest_group(group[1:]):
log.die(f'invalid --groups item {group}: '
'"{group[1:]}" is not a valid group name')
self.extra_groups.append(group)

for group in args.groups:
if ',' in group:
for split_group in group.split(','):
handle(split_group)
if not is_project_group(item[1:]):
log.die(f'invalid --group-filter item {item}: '
f'"{item[1:]}" is not a valid group name')
self.group_filter.append(item)

for item in args.group_filter:
if ',' in item:
for split_item in item.split(','):
handle(split_item)
else:
handle(group)
handle(item)

# We can't blindly call self._projects() here: manifests with
# imports are limited to plain 'west update', and cannot use
Expand Down Expand Up @@ -1153,7 1155,7 @@ def decide_update_strategy(self, project, sha, stats, take_stats):
return current_branch, is_ancestor, try_rebase

def project_is_active(self, project):
return self.manifest.is_active(project, extra_groups=self.extra_groups)
return self.manifest.is_active(project, extra_filter=self.group_filter)

class ForAll(_ProjectCommand):
def __init__(self):
Expand Down Expand Up @@ -1476,8 1478,8 @@ def die_if_no_git():
Default output is limited to "active" projects as determined by the:
- "groups" manifest file section
- "manifest.groups" local configuration option in .west/config
- "group-filter" manifest file section
- "manifest.group-filter" local configuration option in .west/config
To include inactive projects as well, use "--all" or give an explicit
list of projects (by name or path). See the west documentation for
Expand Down
8 changes: 4 additions & 4 deletions src/west/manifest-schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 19,7 @@
#
# --------------------------------------------------------------

schema;groups:
schema;groups-schema:
type: seq
sequence:
- type: str
Expand Down Expand Up @@ -121,14 121,14 @@ mapping:
type: any
groups:
required: false
include: groups
include: groups-schema

# If present, an allowlist/blocklist of project groups. Prefix a
# group name with "-" to block it. Give a group name as-is to
# allow it.
groups:
group-filter:
required: false
include: groups
include: groups-schema

# The "self" key specifies values for the project containing the manifest
# file (the "manifest repository").
Expand Down
Loading

0 comments on commit 06ed61f

Please sign in to comment.