Update version check logic

This commit is contained in:
Yukino Song
2024-08-28 02:59:16 +08:00
parent b8d3ebb248
commit f999f3364b
2 changed files with 5 additions and 4 deletions

View File

@@ -17,6 +17,7 @@ class ApolloVersion {
this.versionMajor = this.versionParts ? this.versionParts[0] : null; this.versionMajor = this.versionParts ? this.versionParts[0] : null;
this.versionMinor = this.versionParts ? this.versionParts[1] : null; this.versionMinor = this.versionParts ? this.versionParts[1] : null;
this.versionPatch = this.versionParts ? this.versionParts[2] : null; this.versionPatch = this.versionParts ? this.versionParts[2] : null;
this.versionIncremental = this.versionParts ? this.versionParts[3] : null;
} }
parseVersion(version) { parseVersion(version) {
@@ -27,10 +28,10 @@ class ApolloVersion {
if (v.indexOf("v") === 0) { if (v.indexOf("v") === 0) {
v = v.substring(1); v = v.substring(1);
} }
return v.split('.').map(Number); return v.split('.').map(i => parseInt(i, 10));
} }
isGreater(otherVersion) { isGreater(otherVersion, checkIncremental) {
let otherVersionParts; let otherVersionParts;
if (otherVersion instanceof ApolloVersion) { if (otherVersion instanceof ApolloVersion) {
otherVersionParts = otherVersion.versionParts; otherVersionParts = otherVersion.versionParts;
@@ -43,7 +44,7 @@ class ApolloVersion {
if (!this.versionParts || !otherVersionParts) { if (!this.versionParts || !otherVersionParts) {
return false; return false;
} }
for (let i = 0; i < Math.min(3, this.versionParts.length, otherVersionParts.length); i++) { for (let i = 0; i < Math.min(checkIncremental && 4 || 3, this.versionParts.length, otherVersionParts.length); i++) {
if (this.versionParts[i] > otherVersionParts[i]) { if (this.versionParts[i] > otherVersionParts[i]) {
return true; return true;
} }

View File

@@ -135,7 +135,7 @@
if (!this.preReleaseVersion || !this.githubVersion || !this.version) { if (!this.preReleaseVersion || !this.githubVersion || !this.version) {
return false; return false;
} }
return this.preReleaseVersion.isGreater(this.version) && this.preReleaseVersion.isGreater(this.githubVersion); return this.preReleaseVersion.isGreater(this.version, true) && this.preReleaseVersion.isGreater(this.githubVersion, true);
}, },
buildVersionIsDirty() { buildVersionIsDirty() {
return this.version.version?.split(".").length === 5 && return this.version.version?.split(".").length === 5 &&