in appengine-plugins-core/src/main/java/com/google/cloud/tools/appengine/operations/cloudsdk/serialization/CloudSdkVersion.java [121:155]
public int compareTo(CloudSdkVersion other) {
Preconditions.checkNotNull(other);
if ("HEAD".equals(version) && !"HEAD".equals(other.version)) {
return 1;
} else if (!"HEAD".equals(version) && "HEAD".equals(other.version)) {
return -1;
}
// First, compare required fields
List<Integer> mine = ImmutableList.of(majorVersion, minorVersion, patchVersion);
List<Integer> others =
ImmutableList.of(other.majorVersion, other.minorVersion, other.patchVersion);
for (int i = 0; i < mine.size(); i++) {
int result = mine.get(i).compareTo(others.get(i));
if (result != 0) {
return result;
}
}
// Compare pre-release components
if (preRelease != null && other.getPreRelease() != null) {
return preRelease.compareTo(other.getPreRelease());
}
// A SemVer with a pre-release string has lower precedence than one without.
if (preRelease == null && other.getPreRelease() != null) {
return 1;
}
if (preRelease != null && other.getPreRelease() == null) {
return -1;
}
return 0;
}