diff options
author | Maria Odea B. Ching <oching@apache.org> | 2007-11-07 09:02:58 +0000 |
---|---|---|
committer | Maria Odea B. Ching <oching@apache.org> | 2007-11-07 09:02:58 +0000 |
commit | c7cd97bf168f75c532ecabbe48b326e3b98407f2 (patch) | |
tree | b2a3be8b10c245a731e0c74167cb8e1e6c9732fd /archiva-base/archiva-common | |
parent | f72ae8a302da90ef6e7a3b90bd9dda7f03495fa5 (diff) | |
download | archiva-c7cd97bf168f75c532ecabbe48b326e3b98407f2.tar.gz archiva-c7cd97bf168f75c532ecabbe48b326e3b98407f2.zip |
[MRM-576]
- modified logic for deleting released snapshots, delete only if there exists a released version of that snapshot not when there is a
higher released/snapshot version
- adjusted tests
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@592657 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-base/archiva-common')
-rw-r--r-- | archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/VersionUtil.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/VersionUtil.java b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/VersionUtil.java index 07aadf674..7ac85e2ac 100644 --- a/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/VersionUtil.java +++ b/archiva-base/archiva-common/src/main/java/org/apache/maven/archiva/common/utils/VersionUtil.java @@ -65,6 +65,8 @@ public class VersionUtil public static final Pattern TIMESTAMP_PATTERN = Pattern.compile( "^([0-9]{8})\\.([0-9]{6})$" ); + public static final Pattern GENERIC_SNAPSHOT_PATTERN = Pattern.compile( "^(.*)-" + SNAPSHOT ); + /** * <p> * Tests if the unknown string contains elements that identify it as a version string (or not). @@ -153,6 +155,38 @@ public class VersionUtil return version; } } + + /** + * <p> + * Get the release version of the snapshot version. + * </p> + * + * <p> + * If snapshot version is 1.0-SNAPSHOT, then release version would be 1.0 + * And if snapshot version is 1.0-20070113.163208-1.jar, then release version would still be 1.0 + * </p> + * + * @param snapshotVersion + * @return + */ + public static String getReleaseVersion( String snapshotVersion ) + { + Matcher m = UNIQUE_SNAPSHOT_PATTERN.matcher( snapshotVersion ); + + if( isGenericSnapshot( snapshotVersion ) ) + { + m = GENERIC_SNAPSHOT_PATTERN.matcher( snapshotVersion ); + } + + if ( m.matches() ) + { + return m.group( 1 ); + } + else + { + return snapshotVersion; + } + } public static boolean isUniqueSnapshot( String version ) { |