Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class SemverGitPlugin implements Plugin<Project> {
}

def static Object[] parseVersion(String version) {
def pattern = /^([0-9]+)\.([0-9]+)\.([0-9]+)(-([a-zA-Z0-9.-]+))?$/
def pattern = /^(?:refs\/tags\/)?([0-9]+)\.([0-9]+)\.([0-9]+)(-([a-zA-Z0-9.-]+))?$/
def matcher = version =~ pattern
def arr = matcher.collect { it }[0]
if (arr == null) {
Expand Down Expand Up @@ -124,4 +124,4 @@ class SemverGitPlugin implements Plugin<Project> {
println "Version: " + project.version
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,22 @@ class SemverGitPluginTest extends GroovyTestCase {
testParseVersion("1.2.3-SNAPSHOT", [1,2,3,"SNAPSHOT"]);
}
void testParseVersion12_34_56_rc78() {
testParseVersion("12.34.56-rc78", [12,34,56,"rc78"]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test name doesn't match the other tests, please restore a copy of the old one or rename the test

testParseVersion("refs/tags/12.34.56-rc78", [12,34,56,"rc78"]);
}
void testParseVersionRefsTags100() {
testParseVersion("refs/tags/1.0.0", [1,0,0,null]);
}
void testParseVersionRefsTags123() {
testParseVersion("refs/tags/1.2.3", [1,2,3,null]);
}
void testParseVersionRefsTags123beta() {
testParseVersion("refs/tags/1.2.3-beta", [1,2,3,"beta"]);
}
void testParseVersionRefsTags123snapshot() {
testParseVersion("refs/tags/1.2.3-SNAPSHOT", [1,2,3,"SNAPSHOT"]);
}
void testParseVersionRefsTags12_34_56_rc78() {
testParseVersion("refs/tags/12.34.56-rc78", [12,34,56,"rc78"]);
}
void testFailParseVersion_abc() {
shouldFail({SemverGitPlugin.parseVersion("a.b.c")});
Expand Down Expand Up @@ -105,4 +120,4 @@ class SemverGitPluginTest extends GroovyTestCase {
testNextVersion("1.0.0-SNAPSHOT", "1.0.0-beta", "major", "SNAPSHOT");
}

}
}