Skip to content

Commit

Permalink
Try to deal with new Google's repositories 'developer version' numbering
Browse files Browse the repository at this point in the history
Signed-off-by: Jorge Ruesga <[email protected]>
  • Loading branch information
jruesga committed Apr 6, 2019
1 parent 8d288e7 commit b168e77
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1667,7 +1667,13 @@ public Observable<Void> deleteChangeRevisionReviewerVote(

@Override
public Observable<ServerVersion> getServerVersion() {
return andCacheVersion(mService.getServerVersion());
return andCacheVersion(SafeObservable.fromNullCallable(() -> {
ServerVersion version = mService.getServerVersion().blockingFirst();
if (version != null && version.isDevelopmentVersion()) {
return version.createDevelepmentVersion();
}
return version;
}));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
package com.ruesga.rview.gerrit.model;

import com.ruesga.rview.gerrit.GerritApi;

import java.util.Locale;

/**
Expand All @@ -31,21 +33,29 @@ public ServerVersion(String version) {
build = version.substring(version.indexOf("-") + 1);
v = version.substring(0, version.indexOf("-")).split("\\.");
}
if (v.length > 0) {
major = readSafeValue(v[0]);
}
if (v.length > 1) {
major = readSafeValue(v[0]);
minor = readSafeValue(v[1]);
}
if (v.length > 2) {
build = v[2];
} else {
build = version;
}
}

public double getVersion() {
return Double.parseDouble(String.format(Locale.getDefault(), "%d.%d", major, minor));
}

public boolean isDevelopmentVersion() {
return major == 0 && minor == 0;
}

public ServerVersion createDevelepmentVersion() {

This comment has been minimized.

Copy link
@maniac103

maniac103 Apr 7, 2019

Collaborator

Typo ;-)

This comment has been minimized.

Copy link
@jruesga

jruesga Apr 7, 2019

Author Owner

Thx :)

return new ServerVersion(GerritApi.API_VERSION + "." + build);
}

private static int readSafeValue(String v) {
try {
return Integer.parseInt(v);
Expand Down

0 comments on commit b168e77

Please sign in to comment.