diff options
author | Edwin Kempin <edwin.kempin@sap.com> | 2011-07-07 07:46:40 +0200 |
---|---|---|
committer | Edwin Kempin <edwin.kempin@sap.com> | 2011-07-11 08:22:00 +0200 |
commit | ac54919987975f8e426d503fb8c65f7878d3d430 (patch) | |
tree | 74cf546342efb62d3aa295b590f8e55942ce7362 | |
parent | 9446af9f0f37fe756421d0f0d41e98cc27e7c703 (diff) | |
download | gerrit-ac54919987975f8e426d503fb8c65f7878d3d430.tar.gz |
Display refs/meta/config branch on ProjectBranchesScreen
The refs/meta/config branch was not shown in the ProjectBranchesScreen
since all refs that were not starting with refs/heads/ were filtered
out. The refs/meta/config branch contains important configuration data
for the project and should therefore be displayed along with the other
branches. With this change the refs/meta/config branch is not ignored
anymore and displayed properly in the ProjectBranchesScreen.
Since refs/meta/config is not just any branch, but has a special
meaning to Gerrit it is always displayed at the top below HEAD.
Change-Id: I2b9d89004a15813ef301ce6ea803b5c4e10b7302
Signed-off-by: Edwin Kempin <edwin.kempin@sap.com>
-rw-r--r-- | gerrit-httpd/src/main/java/com/google/gerrit/httpd/rpc/project/ListBranches.java | 31 |
1 files changed, 20 insertions, 11 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 2762acbc..7be0f668 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 @@ -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)); } |