Skip to content

Commit 1c7b413

Browse files
committed
app: project: list: Add a new "active" format string
In order to be able to display whether a project is active and inactive, add a new "active" format string that resolves to "active" or "inactive". Signed-off-by: Carles Cufi <[email protected]>
1 parent 4f753f0 commit 1c7b413

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

src/west/app/project.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,6 +455,7 @@ def do_add_parser(self, parser_adder):
455455
that the project has been cloned.
456456
- cloned: "cloned" if the project has been cloned, "not-cloned"
457457
otherwise
458+
- active: "active" if the project is currently active, "inactive" otherwise
458459
- clone_depth: project clone depth if specified, "None" otherwise
459460
- groups: project groups, as a comma-separated list
460461
''')
@@ -496,6 +497,11 @@ def cloned_thunk(project):
496497

497498
return "cloned" if project.is_cloned() else "not-cloned"
498499

500+
def active_thunk(project):
501+
self.die_if_no_git()
502+
503+
return "active" if self.manifest.is_active(project) else "inactive"
504+
499505
def delay(func, project):
500506
return DelayFormat(partial(func, project))
501507

@@ -550,6 +556,7 @@ def delay(func, project):
550556
revision=project.revision or 'N/A',
551557
clone_depth=project.clone_depth or "None",
552558
cloned=delay(cloned_thunk, project),
559+
active=delay(active_thunk, project),
553560
sha=delay(sha_thunk, project),
554561
groups=','.join(project.groups))
555562
except KeyError as e:

tests/test_project.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,22 +226,22 @@ def check(command_string, expected):
226226
'bar .. path-for-bar',
227227
'baz .baz-group. baz'])
228228

229-
check(_list_f('{name} .{groups}. {path}') + ['--inactive'],
230-
['foo .foo-group-1,foo-group-2. foo',
231-
'baz .baz-group. baz'])
229+
check(_list_f('{name} .{groups}. {path} {active}') + ['--inactive'],
230+
['foo .foo-group-1,foo-group-2. foo inactive',
231+
'baz .baz-group. baz inactive'])
232232

233-
check(_list_f("{name} .{groups}. {path}") + ['--all'] + 'foo bar'.split(),
234-
['foo .foo-group-1,foo-group-2. foo',
235-
'bar .. path-for-bar'])
233+
check(_list_f("{name} .{groups}. {path} {active}") + ['--all'] + 'foo bar'.split(),
234+
['foo .foo-group-1,foo-group-2. foo inactive',
235+
'bar .. path-for-bar active'])
236236

237237
err_msg = cmd_raises('list -i foo bar', subprocess.CalledProcessError)
238238
assert '-i cannot be combined with an explicit project list' in err_msg
239239

240240
cmd('config manifest.group-filter +foo-group-1')
241-
check(_list_f('{name} .{groups}. {path}'),
242-
['manifest .. zephyr',
243-
'foo .foo-group-1,foo-group-2. foo',
244-
'bar .. path-for-bar'])
241+
check(_list_f('{name} .{groups}. {path} {active}'),
242+
['manifest .. zephyr active',
243+
'foo .foo-group-1,foo-group-2. foo active',
244+
'bar .. path-for-bar active'])
245245

246246

247247
def test_list_sha(west_update_tmpdir):

0 commit comments

Comments
 (0)