Fix VersionCheck (#591)

code dedub

Bugfix & Test Correction

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/591
Reviewed-by: opyale <opyale@noreply.codeberg.org>
This commit is contained in:
6543
2020-07-14 18:20:00 +02:00
parent 673b9f564c
commit 8a7923cba7
2 changed files with 14 additions and 27 deletions

View File

@@ -103,23 +103,7 @@ public class Version {
*/
public boolean less(@NonNull Version v) {
int rounds = Math.min(this.values.size(), v.values.size());
for(int i = 0; i < rounds; i++) {
if(i + 1 == rounds) {
if(this.values.get(i) >= v.values.get(i)) {
return false;
}
}
else {
if(this.values.get(i) > v.values.get(i)) {
return false;
}
else if(this.values.get(i) < v.values.get(i)) {
return true;
}
}
}
return true;
return v.higher(this);
}
@@ -184,13 +168,7 @@ public class Version {
*/
public boolean lessOrEqual(@NonNull Version v) {
int rounds = Math.min(this.values.size(), v.values.size());
for(int i = 0; i < rounds; i++) {
if(this.values.get(i) > v.values.get(i)) {
return false;
}
}
return true;
return v.higherOrEqual(this);
}
@@ -217,9 +195,13 @@ public class Version {
int rounds = Math.min(this.values.size(), v.values.size());
for(int i = 0; i < rounds; i++) {
if(this.values.get(i) < v.values.get(i)) {
if(this.values.get(i) > v.values.get(i)) {
return true;
}
else if(this.values.get(i) < v.values.get(i)) {
return false;
}
}
return true;