mirror of
https://codeberg.org/gitnex/GitNex
synced 2024-12-23 00:48:57 +01:00
Add fallback for missing version information in database (#1175)
### Describe what your pull request does and which issue you’re targeting As described in #1174 the app crashes if a bogus version (empty string) is stored in the database. In case of an empty version information in the database, the fallback should be to gracefully treat this as a version 0. This way every check for a "version greater than" fails. After all the version information will be updated from the server anyways. <br> fixes #1174 <br> - [X] I carefully read the [contribution guidelines](https://codeberg.org/GitNex/GitNex/src/branch/main/CONTRIBUTING.md). - [X] I'm following the code standards as defined [here](https://codeberg.org/gitnex/GitNex/wiki/Code-Standards). - [X] By submitting this pull request, I permit GitNex to license my work under the [GNU General Public License v3](https://codeberg.org/GitNex/GitNex/src/branch/main/LICENSE). Co-authored-by: Fettlaus <mail@fettlaus.de> Reviewed-on: https://codeberg.org/gitnex/GitNex/pulls/1175 Reviewed-by: qwerty287 <qwerty287@noreply.codeberg.org> Co-authored-by: Fettlaus <fettlaus@noreply.codeberg.org> Co-committed-by: Fettlaus <fettlaus@noreply.codeberg.org>
This commit is contained in:
parent
39f961e746
commit
4a3397766f
@ -51,6 +51,10 @@ public class Version {
|
||||
|
||||
final Pattern patternNumberDotNumber = Pattern.compile("^\\d+(\\.(\\d)+)*");
|
||||
|
||||
if(raw.isEmpty()) {
|
||||
raw = "0";
|
||||
}
|
||||
|
||||
if(!valid(raw)) {
|
||||
throw new IllegalArgumentException("Invalid version format: " + raw);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ public class VersionTest {
|
||||
assertTrue(new Version("1.12.0").equal("v1.12"));
|
||||
assertTrue(new Version("v1.12.0").equal("1.12.0"));
|
||||
assertTrue(new Version("0").equal("0"));
|
||||
assertTrue(new Version("").equal("0"));
|
||||
|
||||
assertFalse(new Version("1.12.1").equal("1.12.0+dev-211-g316db0fe7"));
|
||||
assertFalse(new Version("v1.12.0").equal("1.10.0"));
|
||||
@ -35,6 +36,7 @@ public class VersionTest {
|
||||
@Test
|
||||
public void less() {
|
||||
|
||||
assertTrue(new Version("").less("1.11.0"));
|
||||
assertTrue(new Version("1.11.0").less("1.12"));
|
||||
assertTrue(new Version("v1.11").less("1.12.0+dev-211-g316db0fe7"));
|
||||
assertTrue(new Version("1.12.0").less("v2"));
|
||||
|
Loading…
Reference in New Issue
Block a user