New option for ls-user-refs: --only-refs-heads

Allows the admin to filter out refs not residing
in the refs/heads namespace.

Change-Id: I10339f7389a14b94e04d2d64926f17c5001a2206
This commit is contained in:
Gustaf Lundh
2012-11-18 18:24:39 -08:00
committed by David Pursehouse
parent bf53a70b33
commit 2f7bdc1463
2 changed files with 11 additions and 2 deletions

View File

@@ -11,6 +11,7 @@ SYNOPSIS
'ssh' -p <port> <host> 'gerrit ls-user-ref'
[--project PROJECT> | -p <PROJECT>]
[--user <USER> | -u <USER>]
[--only-refs-heads]
DESCRIPTION
-----------
@@ -38,6 +39,9 @@ OPTIONS
will query the database to find matching users, so the
full identity/name does not need to be specified.
--only-refs-heads::
Only list the refs found under refs/heads/*
EXAMPLES
--------

View File

@@ -17,6 +17,7 @@ package com.google.gerrit.sshd.commands;
import com.google.gerrit.common.data.GlobalCapability;
import com.google.gerrit.extensions.annotations.RequiresCapability;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.reviewdb.client.Branch;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.account.AccountResolver;
@@ -62,6 +63,9 @@ public class LsUserRefs extends SshCommand {
usage = "user for which the groups should be listed")
private String userName;
@Option(name = "--only-refs-heads", usage = "list only refs under refs/heads")
private boolean onlyRefsHeads;
@Inject
private GitRepositoryManager repoManager;
@@ -96,9 +100,10 @@ public class LsUserRefs extends SshCommand {
db, true).filter(repo.getAllRefs(), false);
for (final String ref : refsMap.keySet()) {
stdout.println(ref);
if (!onlyRefsHeads || ref.startsWith(Branch.R_HEADS)) {
stdout.println(ref);
}
}
} catch (RepositoryNotFoundException e) {
throw new UnloggedFailure("fatal: '"
+ projectControl.getProject().getNameKey() + "': not a git archive");