Merge pull request #2428 from SiboVG/snapshot
Add snapshot version to OpenRocket versioning system
This commit is contained in:
commit
93b5446e29
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
# The OpenRocket build version
|
# The OpenRocket build version
|
||||||
build.version=23.09
|
build.version=23.09.SNAPSHOT
|
||||||
|
|
||||||
# The copyright year for the build. Displayed in the about dialog.
|
# The copyright year for the build. Displayed in the about dialog.
|
||||||
# Will show as Copyright 2013-${build.copyright}
|
# Will show as Copyright 2013-${build.copyright}
|
||||||
|
@ -39,6 +39,8 @@ public class UpdateInfoRetriever {
|
|||||||
{ "RC", 3 }, // Release Candidate
|
{ "RC", 3 }, // Release Candidate
|
||||||
}).collect(Collectors.toMap(c -> (String) c[0], c -> (Integer) c[1]));
|
}).collect(Collectors.toMap(c -> (String) c[0], c -> (Integer) c[1]));
|
||||||
|
|
||||||
|
public static final String snapshotTag = "SNAPSHOT";
|
||||||
|
|
||||||
/* Enum for the current build version. Values:
|
/* Enum for the current build version. Values:
|
||||||
OLDER: current build version is older than the latest official release
|
OLDER: current build version is older than the latest official release
|
||||||
LATEST: current build is the latest official release
|
LATEST: current build is the latest official release
|
||||||
@ -280,7 +282,7 @@ public class UpdateInfoRetriever {
|
|||||||
public static List<String> filterOfficialRelease(List<String> names) {
|
public static List<String> filterOfficialRelease(List<String> names) {
|
||||||
if (names == null) return null;
|
if (names == null) return null;
|
||||||
return names.stream().filter(c -> Arrays.stream(devTags.keySet().toArray(new String[0]))
|
return names.stream().filter(c -> Arrays.stream(devTags.keySet().toArray(new String[0]))
|
||||||
.noneMatch(c::contains)).collect(Collectors.toList());
|
.noneMatch(c::contains) && !c.contains(snapshotTag)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -358,8 +360,8 @@ public class UpdateInfoRetriever {
|
|||||||
// If the loop is still going until this condition, you have the situation where tag1 is e.g.
|
// If the loop is still going until this condition, you have the situation where tag1 is e.g.
|
||||||
// '15.03' and tag2 '15.03.01', so tag is in that case the more recent version.
|
// '15.03' and tag2 '15.03.01', so tag is in that case the more recent version.
|
||||||
if (i >= tag1Split.length) {
|
if (i >= tag1Split.length) {
|
||||||
// Tag 1 is e.g. '15.03' and tag2 '15.03.01', so tag2 is the more recent version
|
// Tag 1 is e.g. '15.03' and tag2 '15.03.01' or '15.03.SNAPSHOT', so tag2 is the more recent version
|
||||||
if (tag2Split[i].matches("\\d+")) {
|
if (tag2Split[i].matches("\\d+") || snapshotTag.equals(tag2Split[i])) {
|
||||||
return ReleaseStatus.OLDER;
|
return ReleaseStatus.OLDER;
|
||||||
}
|
}
|
||||||
// Tag 1 is e.g. '15.03' and tag2 '15.03.beta.01', so tag1 is the more recent version (it's an official release)
|
// Tag 1 is e.g. '15.03' and tag2 '15.03.beta.01', so tag1 is the more recent version (it's an official release)
|
||||||
@ -392,6 +394,30 @@ public class UpdateInfoRetriever {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle snapshots
|
||||||
|
if (snapshotTag.equals(tag1Split[i]) || snapshotTag.equals(tag2Split[i])) {
|
||||||
|
// In case when e.g. tag1 is '23.09.SNAPSHOT.02' and tag2 '23.09.SNAPSHOT.01', go to the next loop to compare '01' and '02'
|
||||||
|
if (snapshotTag.equals(tag1Split[i]) && snapshotTag.equals(tag2Split[i])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
// In case when e.g. tag1 is '23.09.SNAPSHOT' and tag2 '23.09', tag1 is newer
|
||||||
|
else if (snapshotTag.equals(tag1Split[i])) {
|
||||||
|
// E.g. tag1 is '23.09.SNAPSHOT', tag2 is '23.09.01'
|
||||||
|
if (tag2Split[i].matches("\\d+")) {
|
||||||
|
return ReleaseStatus.OLDER;
|
||||||
|
} else {
|
||||||
|
return ReleaseStatus.NEWER;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// E.g. tag1 is '23.09.01', tag2 is '23.09.SNAPSHOT'
|
||||||
|
if (tag1Split[i].matches("\\d+")) {
|
||||||
|
return ReleaseStatus.NEWER;
|
||||||
|
} else {
|
||||||
|
return ReleaseStatus.OLDER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// In case tag1 is e.g. '20.alpha.01', but tag2 is already an official release with a number instead of
|
// In case tag1 is e.g. '20.alpha.01', but tag2 is already an official release with a number instead of
|
||||||
// a text, e.g. '20.01'
|
// a text, e.g. '20.01'
|
||||||
if (tag2Split[i].matches("\\d+")) {
|
if (tag2Split[i].matches("\\d+")) {
|
||||||
@ -445,7 +471,7 @@ public class UpdateInfoRetriever {
|
|||||||
log.warn(message);
|
log.warn(message);
|
||||||
throw new UpdateCheckerException(message);
|
throw new UpdateCheckerException(message);
|
||||||
}
|
}
|
||||||
if (!devTags.containsKey(tagSplit[i])) {
|
if (!devTags.containsKey(tagSplit[i]) && !snapshotTag.equals(tagSplit[i])) {
|
||||||
String message = String.format("Malformed release tag: '%s'", String.join(".", tagSplit));
|
String message = String.format("Malformed release tag: '%s'", String.join(".", tagSplit));
|
||||||
log.warn(message);
|
log.warn(message);
|
||||||
throw new UpdateCheckerException(message);
|
throw new UpdateCheckerException(message);
|
||||||
|
@ -215,6 +215,30 @@ public class UpdateInfoTest extends BaseTestCase {
|
|||||||
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
||||||
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.02.RC.01", "22.02.02"));
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("22.02.RC.01", "22.02.02"));
|
||||||
|
|
||||||
|
// Test snapshots
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("23.09", "23.09.SNAPSHOT"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.LATEST,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("23.09.SNAPSHOT", "23.09.SNAPSHOT"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("23.09.SNAPSHOT", "23.09"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("24.01", "23.09.SNAPSHOT"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("23.09.SNAPSHOT", "24.01"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("24.01.SNAPSHOT", "23.09"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("23.09.SNAPSHOT.01", "23.09.SNAPSHOT.02"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.LATEST,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("23.09.SNAPSHOT.02", "23.09.SNAPSHOT.02"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("23.09.SNAPSHOT.02", "23.09.SNAPSHOT.01"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.NEWER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("23.09.01", "23.09.SNAPSHOT"));
|
||||||
|
assertEquals(UpdateInfoRetriever.ReleaseStatus.OLDER,
|
||||||
|
UpdateInfoRetriever.UpdateInfoFetcher.compareLatest("23.09.SNAPSHOT", "23.09.01"));
|
||||||
|
|
||||||
|
|
||||||
// Test bogus releases
|
// Test bogus releases
|
||||||
assertExceptionCompareLatest("22.02.gamma.01", "22.02");
|
assertExceptionCompareLatest("22.02.gamma.01", "22.02");
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package net.sf.openrocket.communication;
|
package net.sf.openrocket.communication;
|
||||||
|
|
||||||
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
import net.sf.openrocket.util.BaseTestCase.BaseTestCase;
|
||||||
|
import net.sf.openrocket.util.BuildProperties;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
@ -12,12 +14,15 @@ public class WelcomeInfoTest extends BaseTestCase {
|
|||||||
@Test
|
@Test
|
||||||
public void testWelcomeInfo() throws Exception {
|
public void testWelcomeInfo() throws Exception {
|
||||||
// Test the welcome info for the current build version
|
// Test the welcome info for the current build version
|
||||||
String welcomeInfo = WelcomeInfoRetriever.retrieveWelcomeInfo();
|
String version = BuildProperties.getVersion();
|
||||||
assertNotNull("Current release version not present in release notes", welcomeInfo);
|
if (!version.contains(UpdateInfoRetriever.snapshotTag)) { // Ignore snapshot releases; they don't need release notes
|
||||||
assertTrue("Body of release notes is empty", welcomeInfo.length() > 0);
|
String welcomeInfo = WelcomeInfoRetriever.retrieveWelcomeInfo();
|
||||||
|
assertNotNull("Current release version not present in release notes", welcomeInfo);
|
||||||
|
assertFalse("Body of release notes is empty", welcomeInfo.isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
// Test the release info for a bogus release version
|
// Test the release info for a bogus release version
|
||||||
welcomeInfo = WelcomeInfoRetriever.retrieveWelcomeInfo("bogus release");
|
String welcomeInfo = WelcomeInfoRetriever.retrieveWelcomeInfo("bogus release");
|
||||||
assertNull(welcomeInfo);
|
assertNull(welcomeInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user