Merge "ls-groups: Add option to only list groups that are visible to all"
This commit is contained in:
@@ -10,6 +10,7 @@ SYNOPSIS
|
||||
[verse]
|
||||
'ssh' -p <port> <host> 'gerrit ls-groups'
|
||||
[--project <NAME>]
|
||||
[--visible-to-all]
|
||||
|
||||
DESCRIPTION
|
||||
-----------
|
||||
@@ -38,6 +39,11 @@ OPTIONS
|
||||
projects. In this case all groups are listed that have a
|
||||
permission for any of the specified projects.
|
||||
|
||||
--visible-to-all::
|
||||
Displays only groups that are visible to all registered users
|
||||
(groups that are explicitly marked as visible to all registered
|
||||
users).
|
||||
|
||||
EXAMPLES
|
||||
--------
|
||||
|
||||
|
@@ -45,6 +45,7 @@ public class VisibleGroups {
|
||||
private final GroupDetailFactory.Factory groupDetailFactory;
|
||||
|
||||
private Collection<ProjectControl> projects;
|
||||
private boolean onlyVisibleToAll;
|
||||
|
||||
@Inject
|
||||
VisibleGroups(final Provider<IdentifiedUser> currentUser,
|
||||
@@ -61,6 +62,10 @@ public class VisibleGroups {
|
||||
this.projects = projects;
|
||||
}
|
||||
|
||||
public void setOnlyVisibleToAll(final boolean onlyVisibleToAll) {
|
||||
this.onlyVisibleToAll = onlyVisibleToAll;
|
||||
}
|
||||
|
||||
public GroupList get() throws OrmException, NoSuchGroupException {
|
||||
final Iterable<AccountGroup> groups;
|
||||
if (projects != null && !projects.isEmpty()) {
|
||||
@@ -98,6 +103,9 @@ public class VisibleGroups {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (onlyVisibleToAll && !group.isVisibleToAll()) {
|
||||
continue;
|
||||
}
|
||||
filteredGroups.add(group);
|
||||
}
|
||||
return filteredGroups;
|
||||
|
@@ -41,6 +41,9 @@ public class ListGroupsCommand extends BaseCommand {
|
||||
usage = "projects for which the groups should be listed")
|
||||
private final List<ProjectControl> projects = new ArrayList<ProjectControl>();
|
||||
|
||||
@Option(name = "--visible-to-all", usage = "to list only groups that are visible to all registered users")
|
||||
private boolean visibleToAll;
|
||||
|
||||
@Override
|
||||
public void start(final Environment env) throws IOException {
|
||||
startThread(new CommandRunnable() {
|
||||
@@ -57,6 +60,7 @@ public class ListGroupsCommand extends BaseCommand {
|
||||
try {
|
||||
final VisibleGroups visibleGroups = visibleGroupsFactory.create();
|
||||
visibleGroups.setProjects(projects);
|
||||
visibleGroups.setOnlyVisibleToAll(visibleToAll);
|
||||
final GroupList groupList = visibleGroups.get();
|
||||
for (final GroupDetail groupDetail : groupList.getGroups()) {
|
||||
stdout.print(groupDetail.group.getName() + "\n");
|
||||
|
Reference in New Issue
Block a user