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