ls-projects: new option to list all accessible projects

Add a new option '--all' to the 'ls-projects' SSH command to display
all projects that are accessible by the calling user account. Besides
the projects that the calling user account has been granted 'READ'
access to, this includes all projects that are owned by the calling
user account (even if for these projects the 'READ' access right is
not assigned to the calling user account).

Change-Id: I7e758e49ebff878a37f1fc550cbb63a99ea81818
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
This commit is contained in:
Edwin Kempin
2011-09-22 14:34:02 +02:00
parent 60848f8995
commit f179be219f
2 changed files with 14 additions and 2 deletions

View File

@@ -100,6 +100,9 @@ final class ListProjects extends BaseCommand {
@Option(name = "--description", aliases = {"-d"}, usage = "include description of project in list")
private boolean showDescription;
@Option(name = "--all", usage = "display all projects that are accessible by the calling user")
private boolean all;
private String currentTabSeparator = DEFAULT_TAB_SEPARATOR;
@Override
@@ -134,7 +137,7 @@ final class ListProjects extends BaseCommand {
}
final ProjectControl pctl = e.controlFor(currentUser);
final boolean isVisible = pctl.isVisible();
final boolean isVisible = pctl.isVisible() || (all && pctl.isOwner());
if (showTree) {
treeMap.put(projectName.get(), new TreeNode(pctl.getProject(), isVisible));
continue;
@@ -252,7 +255,8 @@ final class ListProjects extends BaseCommand {
Ref ref = git.getRef(showBranch.get(i));
if (ref != null
&& ref.getObjectId() != null
&& projectControl.controlForRef(ref.getLeaf().getName()).isVisible()) {
&& (projectControl.controlForRef(ref.getLeaf().getName()).isVisible())
|| (all && projectControl.isOwner())) {
result[i] = ref;
}
}