fix: handle maven release plugin generated tags
Look like 'my-awesome-project-0.1.0'; need to use a Pattern to slice out the semver triplet.
This pull request fixes a bug found while converting a project that previously used the maven-release-plugin; the tags generated by that plugin start with the project name, and can't be parsed by the Java SemVer library as is.
See https://git.doit.wisc.edu/adi-ia/bucky-backup-app/merge_requests/5
Merge request reports
Activity
Build finished. Tests FAILED. Build results available at: https://ia-builds.doit.wisc.edu:8443/job/continuous-publish-plugin-master-pull-requests/14/
Added 1 commit:
- 078885f4 - fix: remove unused import
Build finished. Tests PASSED. Build results available at: https://ia-builds.doit.wisc.edu:8443/job/continuous-publish-plugin-master-pull-requests/15/
38 public void describe_maven_release_plugin_style_tags() { 39 CompareVersions.compare("my-awesome-project-0.2.0-13-g98171dc", "0.2.1") 40 } 41 42 @Test 43 void "parseVersionFromGitDescribe control"() { 44 assertEquals(Version.valueOf("0.0.1"), CompareVersions.parseVersionFromGitDescribe("0.0.1")) 45 } 46 @Test 47 void "parseVersionFromGitDescribe with preReleaseVersion"() { 48 assertEquals(Version.valueOf("0.20.7"), CompareVersions.parseVersionFromGitDescribe("0.20.7-1-gfbe61fd")) 49 } 50 @Test 51 void "parseVersionFromGitDescribe maven release plugin formatted tag"() { 52 assertEquals(Version.valueOf("0.2.0"), CompareVersions.parseVersionFromGitDescribe("my-awesome-project-0.2.0-13-g98171dc")) 53 } With these test names, it's a bit hard to get a sense of the overall responsibilities of the class under test. Consider summarizing the business rule & refactoring to reduce duplication with a loop or Spock data table, like
@Test void "should parse common formats" (String version, String input) { expect: Version.valueOf(version) == CompareVersions.parseVersionFromGitDescribe(input) where: version | input "0.0.1" | "0.0.1" "0.20.7" | "0.20.7-1-gfbe61fd" "0.2.0" | "my-awesome-project-0.2.0-13-g98171dc" }
mentioned in commit 6673592b