diff options
Diffstat (limited to 'gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ListBranches.java')
-rw-r--r-- | gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ListBranches.java | 37 |
1 files changed, 23 insertions, 14 deletions
diff --git a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ListBranches.java b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ListBranches.java index 2762acbcc0..68fde4511e 100644 --- a/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ListBranches.java +++ b/gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ListBranches.java @@ -16,9 +16,9 @@ package com.google.gerrit.httpd.rpc.project; import com.google.gerrit.common.data.ListBranchesResult; import com.google.gerrit.httpd.rpc.Handler; -import com.google.gerrit.reviewdb.Branch; -import com.google.gerrit.reviewdb.Project; -import com.google.gerrit.reviewdb.RevId; +import com.google.gerrit.reviewdb.client.Branch; +import com.google.gerrit.reviewdb.client.Project; +import com.google.gerrit.reviewdb.client.RevId; import com.google.gerrit.server.git.GitRepositoryManager; import com.google.gerrit.server.project.NoSuchProjectException; import com.google.gerrit.server.project.ProjectControl; @@ -69,6 +69,7 @@ class ListBranches extends Handler<ListBranchesResult> { final List<Branch> branches = new ArrayList<Branch>(); Branch headBranch = null; + Branch configBranch = null; final Set<String> targets = new HashSet<String>(); final Repository db; @@ -128,18 +129,13 @@ class ListBranches extends Handler<ListBranchesResult> { continue; } - RefControl refControl = pctl.controlForRef(ref.getName()); - - if (ref.getName().startsWith(Constants.R_HEADS) - && refControl.isVisible()) { - final Branch b = createBranch(ref.getName()); - if (ref.getObjectId() != null) { - b.setRevision(new RevId(ref.getObjectId().name())); + final RefControl refControl = pctl.controlForRef(ref.getName()); + if (refControl.isVisible()) { + if (ref.getName().startsWith(Constants.R_HEADS)) { + branches.add(createBranch(ref, refControl, targets)); + } else if (GitRepositoryManager.REF_CONFIG.equals(ref.getName())) { + configBranch = createBranch(ref, refControl, targets); } - - b.setCanDelete(!targets.contains(ref.getName()) && refControl.canDelete()); - - branches.add(b); } } } finally { @@ -151,12 +147,25 @@ class ListBranches extends Handler<ListBranchesResult> { return a.getName().compareTo(b.getName()); } }); + if (configBranch != null) { + branches.add(0, configBranch); + } if (headBranch != null) { branches.add(0, headBranch); } return new ListBranchesResult(branches, pctl.canAddRefs(), false); } + private Branch createBranch(final Ref ref, final RefControl refControl, + final Set<String> targets) { + final Branch b = createBranch(ref.getName()); + if (ref.getObjectId() != null) { + b.setRevision(new RevId(ref.getObjectId().name())); + } + b.setCanDelete(!targets.contains(ref.getName()) && refControl.canDelete()); + return b; + } + private Branch createBranch(final String name) { return new Branch(new Branch.NameKey(projectName, name)); } |