summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Frysinger <vapier@google.com>2021-03-25 02:06:56 -0400
committerMike Frysinger <vapier@google.com>2021-04-13 22:42:32 +0000
commite2effe11a57508f04632cca543292d6568572905 (patch)
treeeb820ef043824579e6754886bca5d817e0c3c67d
parent151701e85f0beb1a7c896eb82c0d1f55ee380567 (diff)
downloadgit-repo-e2effe11a57508f04632cca543292d6568572905.tar.gz
list: add option to show non-checkedout projects too
Currently, list only shows projects that exist in the checkout, and doesn't offer any way to list all projects in the manifest (based on the current settings, or on the options passed to list). This seems to be the opposite of what (at least some) users expect, so let's add an option to show all of them regardless of checkout state. Change-Id: I94bbdc5bd0ff2a411704fa215e7fc2b60fa3360e Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/301263 Reviewed-by: Raman Tenneti <rtenneti@google.com> Tested-by: Mike Frysinger <vapier@google.com>
-rw-r--r--subcmds/list.py15
1 files changed, 12 insertions, 3 deletions
diff --git a/subcmds/list.py b/subcmds/list.py
index 7825dee1..0dfaf317 100644
--- a/subcmds/list.py
+++ b/subcmds/list.py
@@ -25,6 +25,11 @@ class List(Command, MirrorSafeCommand):
25 helpDescription = """ 25 helpDescription = """
26List all projects; pass '.' to list the project for the cwd. 26List all projects; pass '.' to list the project for the cwd.
27 27
28By default, only projects that currently exist in the checkout are shown. If
29you to list all projects (using the specified filter settings), use the --all
30option. If you want to show all projects regardless of the manifest groups,
31then also pass --groups all.
32
28This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'. 33This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
29""" 34"""
30 35
@@ -35,6 +40,9 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
35 p.add_option('-g', '--groups', 40 p.add_option('-g', '--groups',
36 dest='groups', 41 dest='groups',
37 help="Filter the project list based on the groups the project is in") 42 help="Filter the project list based on the groups the project is in")
43 p.add_option('-a', '--all',
44 action='store_true',
45 help='Show projects regardless of checkout state')
38 p.add_option('-f', '--fullpath', 46 p.add_option('-f', '--fullpath',
39 dest='fullpath', action='store_true', 47 dest='fullpath', action='store_true',
40 help="Display the full work tree path instead of the relative path") 48 help="Display the full work tree path instead of the relative path")
@@ -61,7 +69,7 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
61 args: Positional args. Can be a list of projects to list, or empty. 69 args: Positional args. Can be a list of projects to list, or empty.
62 """ 70 """
63 if not opt.regex: 71 if not opt.regex:
64 projects = self.GetProjects(args, groups=opt.groups) 72 projects = self.GetProjects(args, groups=opt.groups, missing_ok=opt.all)
65 else: 73 else:
66 projects = self.FindProjects(args) 74 projects = self.FindProjects(args)
67 75
@@ -79,5 +87,6 @@ This is similar to running: repo forall -c 'echo "$REPO_PATH : $REPO_PROJECT"'.
79 else: 87 else:
80 lines.append("%s : %s" % (_getpath(project), project.name)) 88 lines.append("%s : %s" % (_getpath(project), project.name))
81 89
82 lines.sort() 90 if lines:
83 print('\n'.join(lines)) 91 lines.sort()
92 print('\n'.join(lines))