Add static shortName() method to RefNames and use it.
This prevents some proliferation of the same logic. Change-Id: I5a46976487bf3d264443db114e8fed16805e390c
This commit is contained in:
parent
7b952347fe
commit
9d8b1361ca
@ -17,15 +17,13 @@ package com.google.gerrit.client.projects;
|
||||
import com.google.gerrit.client.WebLinkInfo;
|
||||
import com.google.gerrit.client.actions.ActionInfo;
|
||||
import com.google.gerrit.client.rpc.NativeMap;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.RefNames;
|
||||
import com.google.gwt.core.client.JavaScriptObject;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
|
||||
public class BranchInfo extends JavaScriptObject {
|
||||
public final String getShortName() {
|
||||
return ref().startsWith(Branch.R_HEADS)
|
||||
? ref().substring(Branch.R_HEADS.length())
|
||||
: ref();
|
||||
return RefNames.shortName(ref());
|
||||
}
|
||||
|
||||
public final native String ref() /*-{ return this.ref; }-*/;
|
||||
|
@ -19,7 +19,6 @@ import com.google.gerrit.client.projects.BranchInfo;
|
||||
import com.google.gerrit.client.projects.ProjectApi;
|
||||
import com.google.gerrit.client.rpc.GerritCallback;
|
||||
import com.google.gerrit.client.rpc.Natives;
|
||||
import com.google.gerrit.reviewdb.client.Branch;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gwt.core.client.JsArray;
|
||||
import com.google.gwt.user.client.ui.FlowPanel;
|
||||
@ -91,10 +90,7 @@ public abstract class CreateChangeDialog extends TextAreaActionDialog {
|
||||
|
||||
@Override
|
||||
public String getDisplayString() {
|
||||
if (branch.ref().startsWith(Branch.R_HEADS)) {
|
||||
return branch.ref().substring(Branch.R_HEADS.length());
|
||||
}
|
||||
return branch.ref();
|
||||
return branch.getShortName();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,15 +57,7 @@ public final class Branch {
|
||||
}
|
||||
|
||||
public String getShortName() {
|
||||
final String n = get();
|
||||
|
||||
// Git style branches will tend to start with "refs/heads/".
|
||||
//
|
||||
if (n.startsWith(R_HEADS)) {
|
||||
return n.substring(R_HEADS.length());
|
||||
}
|
||||
|
||||
return n;
|
||||
return RefNames.shortName(get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,6 +56,12 @@ public class RefNames {
|
||||
return (ref.startsWith(REFS) ? "" : REFS_HEADS) + ref;
|
||||
}
|
||||
|
||||
public static final String shortName(String ref) {
|
||||
return ref.startsWith(REFS_HEADS)
|
||||
? ref.substring(REFS_HEADS.length())
|
||||
: ref;
|
||||
}
|
||||
|
||||
public static String refsUsers(Account.Id accountId) {
|
||||
StringBuilder r = new StringBuilder();
|
||||
r.append(REFS_USER);
|
||||
|
Loading…
Reference in New Issue
Block a user