Fix handling of snapshot plugin dependencies

This commit is contained in:
Sebastian Sdorra
2020-10-22 14:09:52 +02:00
parent 49607236e5
commit 1195026fe6
4 changed files with 32 additions and 2 deletions

View File

@@ -14,6 +14,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Changed
- Centralise syntax highlighting ([#1382](https://github.com/scm-manager/scm-manager/pull/1382))
### Fixed
- Handling of snapshot plugin dependencies ([#1384](https://github.com/scm-manager/scm-manager/pull/1384))
## [2.6.3] - 2020-10-16
### Fixed
- Missing default permission to manage public gpg keys ([#1377](https://github.com/scm-manager/scm-manager/pull/1377))

View File

@@ -31,6 +31,8 @@ import com.google.common.base.Preconditions;
import com.google.common.collect.ComparisonChain;
import java.util.Locale;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
//~--- JDK imports ------------------------------------------------------------
@@ -43,6 +45,8 @@ import java.util.Locale;
public final class Version implements Comparable<Version>
{
private static final Pattern MAVEN_UNIQUE_SNAPSHOT = Pattern.compile("-[0-9]{8}\\.[0-9]{6}-[0-9]+");
/**
* Constructs a new version object
*
@@ -388,10 +392,15 @@ public final class Version implements Comparable<Version>
{
String qualifier = qualifierPart.trim().toLowerCase(Locale.ENGLISH);
if (qualifier.contains("snapshot"))
{
if (qualifier.contains("snapshot")) {
snapshot = true;
qualifier = qualifier.replace("snapshot", "");
} else {
Matcher matcher = MAVEN_UNIQUE_SNAPSHOT.matcher(qualifier);
if (matcher.matches()) {
snapshot = true;
qualifier = matcher.replaceAll("-");
}
}
if (qualifier.length() > 0)

View File

@@ -145,4 +145,11 @@ class VersionTest {
void testUnparseable() {
assertThrows(VersionParseException.class, () -> Version.parse("aaaa"));
}
@Test
void shouldDetectUniqueMavenSnapshotVersion() {
Version version = Version.parse("1.0.0-20201022.094711-15");
assertThat(version.isSnapshot()).isTrue();
assertThat(version).hasToString("1.0.0-SNAPSHOT");
}
}

View File

@@ -144,6 +144,17 @@ class PluginInstallationVerifierTest {
PluginInstallationVerifier.verify(context, descriptor);
}
@Test
@SuppressWarnings("squid:S2699") // we are happy if no exception is thrown
void shouldVerifyPluginWithSnapshotDependencies() {
matchConditions();
PluginInstallationContext context = mockInstallationOf(IID_PLUGIN, "1.0.0-SNAPSHOT");
mockDependingOf(IID_PLUGIN, "1.0.0-20201022.094711-15");
PluginInstallationVerifier.verify(context, descriptor);
}
@Test
@SuppressWarnings("squid:S2699") // we are happy if no exception is thrown
void shouldVerifyPluginWithOptionalDependency() {