Skip to content
Snippets Groups Projects

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

cc @paul.erickson

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
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"
       } 
  • Author Contributor

    That is nice - I'll take a look at integrating spock in a future PR.

  • Nicholas Blair Status changed to merged

    Status changed to merged

  • Nicholas Blair mentioned in commit 6673592b

    mentioned in commit 6673592b

  • Please register or sign in to reply
    Loading