Make Gerrit.getVersion public for other code to use
This may be useful to embed into a URL, such as to ensure that
the URL is loaded at least once per application version seen by
a browser.
Signed-off-by: Shawn O. Pearce <sop@google.com>
diff --git a/src/main/java/com/google/gerrit/client/Gerrit.java b/src/main/java/com/google/gerrit/client/Gerrit.java
index 5e709d9..8ebadcb 100644
--- a/src/main/java/com/google/gerrit/client/Gerrit.java
+++ b/src/main/java/com/google/gerrit/client/Gerrit.java
@@ -57,6 +57,7 @@
public static final GerritIcons ICONS = GWT.create(GerritIcons.class);
public static final SystemInfoService SYSTEM_SVC;
+ private static String myVersion;
private static Account myAccount;
private static final ArrayList<SignedInListener> signedInListeners =
new ArrayList<SignedInListener>();
@@ -232,18 +233,25 @@
private static void populateBottomMenu() {
final RootPanel btmmenu = RootPanel.get("gerrit_btmmenu");
- final String vs;
- if (GWT.isScript()) {
- final GerritVersion v = GWT.create(GerritVersion.class);
- vs = v.version();
- } else {
- vs = "dev";
- }
+ final String vs = getVersion();
final HTML version = new HTML(M.poweredBy(vs));
version.setStyleName("gerrit-version");
btmmenu.add(version);
}
+ /** @return version number of the Gerrit application software */
+ public static String getVersion() {
+ if (myVersion == null) {
+ if (GWT.isScript()) {
+ final GerritVersion v = GWT.create(GerritVersion.class);
+ myVersion = v.version();
+ } else {
+ myVersion = "dev";
+ }
+ }
+ return myVersion;
+ }
+
private void onModuleLoad2() {
if (Cookies.getCookie(ACCOUNT_COOKIE) != null
|| Common.getGerritConfig().getLoginType() == SystemConfig.LoginType.HTTP) {