Skip to content

Commit

Permalink
Consider dev tag in version comparison (#2312)
Browse files Browse the repository at this point in the history
* consider dev tag in version comparison

* add changelog

* Update CHANGELOG.md
  • Loading branch information
chriba authored and tobiasdiez committed Nov 24, 2016
1 parent d8714d1 commit 64306e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ We refer to [GitHub issues](https://github.com/JabRef/jabref/issues) by using `#
- We fixed an issue where the file permissions of the .bib-file were changed upon saving [#2279](https://github.com/JabRef/jabref/issues/2279).
- We fixed an issue which prevented that a database was saved successfully if JabRef failed to generate new BibTeX-keys [#2285](https://github.com/JabRef/jabref/issues/2285).
- We fixed an issue when JabRef restores its session and a shared database was used: The error message "No suitable driver found" will not appear.
- Update check now correctly notifies about new release if development version is used. [#2298](https://github.com/JabRef/jabref/issues/2298)

### Removed

Expand Down
7 changes: 6 additions & 1 deletion src/main/java/net/sf/jabref/logic/util/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ public boolean isNewerThan(Version otherVersion) {
return true;
} else if (this.getPatch() == otherVersion.getPatch()) {
// if the patch numbers are equal compare the development stages
return this.developmentStage.isMoreStableThan(otherVersion.developmentStage);
if (this.developmentStage.isMoreStableThan(otherVersion.developmentStage)) {
return true;
} else if (this.developmentStage == otherVersion.developmentStage) {
// if the stage is equal check if this version is in development and the other is not
return !this.isDevelopmentVersion && otherVersion.isDevelopmentVersion;
}
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/test/java/net/sf/jabref/logic/util/VersionTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void validVersionIsNotNewerThanUnknownVersion() {
}

@Test
public void unknownVersionIsNotNewerThanvalidVersion() {
public void unknownVersionIsNotNewerThanValidVersion() {
Version unknownVersion = Version.parse(BuildInfo.UNKNOWN_VERSION);
Version validVersion = Version.parse("4.2");
assertFalse(unknownVersion.isNewerThan(validVersion));
Expand Down Expand Up @@ -146,6 +146,14 @@ public void versionNewerThanDevTwoDigits() {
assertTrue(newer.isNewerThan(older));
}

@Test
public void versionNewerThanDevVersion() {
Version older = Version.parse("1.2dev");
Version newer = Version.parse("1.2");
assertTrue(newer.isNewerThan(older));
assertFalse(older.isNewerThan(newer));
}

@Test
public void versionNewerThanDevThreeDigits() {
Version older = Version.parse("4.2.1");
Expand Down

0 comments on commit 64306e4

Please sign in to comment.