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>
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 2762acb..7be0f66 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 @@
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 @@
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 @@
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));
}