From 53315460869892798c26e6d5be98686a35e95e00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=B0=8F=E7=9A=84=E5=A4=A7=E8=82=A5?= <11911839@mail.sustech.edu.cn> Date: Thu, 17 Mar 2022 10:54:31 +0800 Subject: [PATCH 1/4] Fix for issue 8563 --- CHANGELOG.md | 2 + src/main/java/org/jabref/gui/JabRefFrame.java | 4 +- .../java/org/jabref/logic/util/Version.java | 38 ++++++++++++++----- .../org/jabref/logic/util/VersionTest.java | 30 ++++++++++++++- 4 files changed, 60 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 343d5ab17d5..4fb4a35bfcb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Added - We added an extra option when right-clicking an entry in the Entry List to copy either the DOI or the DOI url. +- We added an extra verification of judge newer version. We also lead you to different change log when you click Help/About JabRef/What's new in this version to fit in different unstable subtypes. ### Changed @@ -32,6 +33,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue when reading non-UTF-8 encoded. When no encoding header is present, the encoding is now detected from the file content (and the preference option is disregarded) [#8417](https://github.com/JabRef/jabref/issues/8417) - We fixed an issue where pasting a URL was replacing + signs by spaces making the URL unreachable. [#8448](https://github.com/JabRef/jabref/issues/8448) - We fixed an issue where creating subsidiary files from aux files created with some versions of biblatex would produce incorrect results. [#8513](https://github.com/JabRef/jabref/issues/8513) +- We fixed an issue where open the help/JabRef resources/view change log leads to 404 [#8563](https://github.com/JabRef/jabref/issues/8563) ### Removed diff --git a/src/main/java/org/jabref/gui/JabRefFrame.java b/src/main/java/org/jabref/gui/JabRefFrame.java index 3d774c3eab1..7c33904a81e 100644 --- a/src/main/java/org/jabref/gui/JabRefFrame.java +++ b/src/main/java/org/jabref/gui/JabRefFrame.java @@ -565,7 +565,7 @@ public LibraryTab getLibraryTabAt(int i) { */ public List getLibraryTabs() { return tabbedPane.getTabs().stream() - .filter(LibraryTab.class::isInstance) + .filter(LibraryTab.class::isInstance) .map(LibraryTab.class::cast) .collect(Collectors.toList()); } @@ -892,7 +892,7 @@ private MenuBar createMenu() { new SeparatorMenuItem(), factory.createMenuItem(StandardActions.OPEN_DEV_VERSION_LINK, new OpenBrowserAction("https://builds.jabref.org/master/")), - factory.createMenuItem(StandardActions.OPEN_CHANGELOG, new OpenBrowserAction("https://github.com/JabRef/jabref/blob/master/CHANGELOG.md")) + factory.createMenuItem(StandardActions.OPEN_CHANGELOG, new OpenBrowserAction("https://github.com/JabRef/jabref/blob/main/CHANGELOG.md")) ), factory.createMenuItem(StandardActions.ABOUT, new AboutAction()) ); diff --git a/src/main/java/org/jabref/logic/util/Version.java b/src/main/java/org/jabref/logic/util/Version.java index 567fdbb8403..336f68e05d0 100644 --- a/src/main/java/org/jabref/logic/util/Version.java +++ b/src/main/java/org/jabref/logic/util/Version.java @@ -27,7 +27,7 @@ public class Version { private static final Version UNKNOWN_VERSION = new Version(); - private final static Pattern VERSION_PATTERN = Pattern.compile("(?\\d+)(\\.(?\\d+))?(\\.(?\\d+))?(?-alpha|-beta)?(?-?dev)?.*"); + private final static Pattern VERSION_PATTERN = Pattern.compile("(?\\d+)(\\.(?\\d+))?(\\.(?\\d+))?(?-alpha|-beta)?(?\\d+)?(?-?dev)?.*"); private final static Pattern CI_SUFFIX_PATTERN = Pattern.compile("-ci\\.\\d+"); private static final String JABREF_GITHUB_RELEASES = "https://api.github.com/repos/JabRef/JabRef/releases"; @@ -37,6 +37,7 @@ public class Version { private int minor = -1; private int patch = -1; private DevelopmentStage developmentStage = DevelopmentStage.UNKNOWN; + private int developmentNum = -1; private boolean isDevelopmentVersion; /** @@ -75,6 +76,10 @@ public static Version parse(String version) { String versionStageString = matcher.group("stage"); parsedVersion.developmentStage = versionStageString == null ? DevelopmentStage.STABLE : DevelopmentStage.parse(versionStageString); + + String stageNumString = matcher.group("num"); + parsedVersion.developmentNum = stageNumString == null ? 0 : Integer.parseInt(stageNumString); + parsedVersion.isDevelopmentVersion = matcher.group("dev") != null; } catch (NumberFormatException e) { LOGGER.warn("Invalid version string used: " + version, e); @@ -138,8 +143,13 @@ public boolean isNewerThan(Version otherVersion) { 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; + // if the development stage are equal compare the development number + if (this.getDevelopmentNum() > otherVersion.getDevelopmentNum()) { + return true; + } else if (this.getDevelopmentNum() == otherVersion.getDevelopmentNum()) { + // if the stage is equal check if this version is in development and the other is not + return !this.isDevelopmentVersion && otherVersion.isDevelopmentVersion; + } } } } @@ -148,8 +158,7 @@ public boolean isNewerThan(Version otherVersion) { } /** - * Checks if this version should be updated to one of the given ones. - * Ignoring the other Version if this one is Stable and the other one is not. + * Checks if this version should be updated to one of the given ones. Ignoring the other Version if this one is Stable and the other one is not. * * @return The version this one should be updated to, or an empty Optional */ @@ -165,8 +174,7 @@ public Optional shouldBeUpdatedTo(List availableVersions) { } /** - * Checks if this version should be updated to the given one. - * Ignoring the other Version if this one is Stable and the other one is not. + * Checks if this version should be updated to the given one. Ignoring the other Version if this one is Stable and the other one is not. * * @return True if this version should be updated to the given one */ @@ -197,6 +205,10 @@ public int getPatch() { return patch; } + public int getDevelopmentNum() { + return developmentNum; + } + public boolean isDevelopmentVersion() { return isDevelopmentVersion; } @@ -206,7 +218,7 @@ public boolean isDevelopmentVersion() { */ public String getChangelogUrl() { if (isDevelopmentVersion) { - return "https://github.com/JabRef/jabref/blob/master/CHANGELOG.md#unreleased"; + return "https://github.com/JabRef/jabref/blob/main/CHANGELOG.md#unreleased"; } else { StringBuilder changelogLink = new StringBuilder() .append("https://github.com/JabRef/jabref/blob/v") @@ -221,8 +233,14 @@ public String getChangelogUrl() { } changelogLink - .append(this.developmentStage.stage) - .append("/CHANGELOG.md"); + .append(this.developmentStage.stage); + + if (this.getDevelopmentNum() != 0) { + changelogLink + .append(this.getDevelopmentNum()); + } + + changelogLink.append("/CHANGELOG.md"); return changelogLink.toString(); } diff --git a/src/test/java/org/jabref/logic/util/VersionTest.java b/src/test/java/org/jabref/logic/util/VersionTest.java index 438225fa712..e2ef6b3e903 100644 --- a/src/test/java/org/jabref/logic/util/VersionTest.java +++ b/src/test/java/org/jabref/logic/util/VersionTest.java @@ -193,6 +193,20 @@ public void versionNotNewerPatch() { assertFalse(older.isNewerThan(newer)); } + @Test + public void versionNewerDevelopmentNumber() { + Version older = Version.parse("4.2-beta1"); + Version newer = Version.parse("4.2-beta2"); + assertFalse(older.isNewerThan(newer)); + } + + @Test + public void versionNotNewerDevelopmentNumber() { + Version older = Version.parse("4.2-beta2"); + Version newer = Version.parse("4.2-beta2"); + assertFalse(newer.isNewerThan(older)); + } + @Test public void equalVersionsNotNewer() { Version version1 = Version.parse("4.2.2"); @@ -203,13 +217,25 @@ public void equalVersionsNotNewer() { @Test public void changelogOfDevelopmentVersionWithDash() { Version version = Version.parse("4.0-dev"); - assertEquals("https://github.com/JabRef/jabref/blob/master/CHANGELOG.md#unreleased", version.getChangelogUrl()); + assertEquals("https://github.com/JabRef/jabref/blob/main/CHANGELOG.md#unreleased", version.getChangelogUrl()); } @Test public void changelogOfDevelopmentVersionWithoutDash() { Version version = Version.parse("3.7dev"); - assertEquals("https://github.com/JabRef/jabref/blob/master/CHANGELOG.md#unreleased", version.getChangelogUrl()); + assertEquals("https://github.com/JabRef/jabref/blob/main/CHANGELOG.md#unreleased", version.getChangelogUrl()); + } + + @Test + public void changelogOfDevelopmentStageSubNumber() { + Version version1 = Version.parse("4.0"); + Version version2 = Version.parse("4.0-beta"); + Version version3 = Version.parse("4.0-beta2"); + Version version4 = Version.parse("4.0-beta3"); + assertEquals("https://github.com/JabRef/jabref/blob/v4.0/CHANGELOG.md", version1.getChangelogUrl()); + assertEquals("https://github.com/JabRef/jabref/blob/v4.0-beta/CHANGELOG.md", version2.getChangelogUrl()); + assertEquals("https://github.com/JabRef/jabref/blob/v4.0-beta2/CHANGELOG.md", version3.getChangelogUrl()); + assertEquals("https://github.com/JabRef/jabref/blob/v4.0-beta3/CHANGELOG.md", version4.getChangelogUrl()); } @Test From 75a73190e536e7445049d11d9c9d3d271ae63a12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E5=B0=8F=E7=9A=84=E5=A4=A7=E8=82=A5?= <11911839@mail.sustech.edu.cn> Date: Fri, 18 Mar 2022 10:23:15 +0800 Subject: [PATCH 2/4] Update CHANGELOG.md Co-authored-by: Christoph --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4fb4a35bfcb..d271ba99426 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Added - We added an extra option when right-clicking an entry in the Entry List to copy either the DOI or the DOI url. -- We added an extra verification of judge newer version. We also lead you to different change log when you click Help/About JabRef/What's new in this version to fit in different unstable subtypes. +- We improved the Version check to take also beta version into account and now redirect to the right changelog for the version ### Changed From 77e1033493f6f070c3f2903c4fd2e9db4006fe24 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sat, 26 Mar 2022 11:35:41 +0100 Subject: [PATCH 3/4] Fix typos --- CHANGELOG.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 217162493bc..eb9fc877f1b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve ### Added - We added an extra option when right-clicking an entry in the Entry List to copy either the DOI or the DOI url. -- We improved the Version check to take also beta version into account and now redirect to the right changelog for the version +- We improved the version check to take also beta version into account and now redirect to the right changelog for the version - We added two new web and fulltext fetchers: SemanticScholar and ResearchGate ### Changed @@ -35,7 +35,7 @@ Note that this project **does not** adhere to [Semantic Versioning](http://semve - We fixed an issue when reading non-UTF-8 encoded. When no encoding header is present, the encoding is now detected from the file content (and the preference option is disregarded) [#8417](https://github.com/JabRef/jabref/issues/8417) - We fixed an issue where pasting a URL was replacing + signs by spaces making the URL unreachable. [#8448](https://github.com/JabRef/jabref/issues/8448) - We fixed an issue where creating subsidiary files from aux files created with some versions of biblatex would produce incorrect results. [#8513](https://github.com/JabRef/jabref/issues/8513) -- We fixed an issue where openign the changelog from withing JabRef ledd to a 404 error [#8563](https://github.com/JabRef/jabref/issues/8563) +- We fixed an issue where opening the changelog from withing JabRef led to a 404 error [#8563](https://github.com/JabRef/jabref/issues/8563) - We fixed an issue where not all found unlinked local files were imported correctly due to some race condition. [#8444](https://github.com/JabRef/jabref/issues/8444) ### Removed From b63d81ad6a1b9104fb0e6a9b088debb0e91f20f9 Mon Sep 17 00:00:00 2001 From: Oliver Kopp Date: Sat, 26 Mar 2022 11:38:26 +0100 Subject: [PATCH 4/4] Fix test name --- src/test/java/org/jabref/logic/util/VersionTest.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/test/java/org/jabref/logic/util/VersionTest.java b/src/test/java/org/jabref/logic/util/VersionTest.java index e2ef6b3e903..5e04e7d234a 100644 --- a/src/test/java/org/jabref/logic/util/VersionTest.java +++ b/src/test/java/org/jabref/logic/util/VersionTest.java @@ -201,10 +201,10 @@ public void versionNewerDevelopmentNumber() { } @Test - public void versionNotNewerDevelopmentNumber() { - Version older = Version.parse("4.2-beta2"); - Version newer = Version.parse("4.2-beta2"); - assertFalse(newer.isNewerThan(older)); + public void versionNotNewerThanSameVersionWithBeta() { + Version version1 = Version.parse("4.2-beta2"); + Version version2 = Version.parse("4.2-beta2"); + assertFalse(version2.isNewerThan(version1)); } @Test