Skip to content

Commit c587a09

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 8cba507 commit c587a09

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

src/west/app/project.py

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

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

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

@@ -547,6 +553,7 @@ def delay(func, project):
547553
revision=project.revision or 'N/A',
548554
clone_depth=project.clone_depth or "None",
549555
cloned=delay(cloned_thunk, project),
556+
active=delay(active_thunk, project),
550557
sha=delay(sha_thunk, project),
551558
groups=','.join(project.groups))
552559
except KeyError as e:

tests/test_project.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -225,23 +225,23 @@ def check(command_string, expected):
225225
'bar .. path-for-bar',
226226
'baz .baz-group. baz'])
227227

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

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

236-
check(_list_f("{name} .{groups}. {path}") + ['--inactive'] + 'foo bar'.split(),
237-
['foo .foo-group-1,foo-group-2. foo',
238-
'bar .. path-for-bar'])
236+
check(_list_f("{name} .{groups}. {path} {active}") + ['--inactive'] + 'foo bar'.split(),
237+
['foo .foo-group-1,foo-group-2. foo inactive',
238+
'bar .. path-for-bar active'])
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)