Skip to content

Commit

Permalink
Make build optional (#4)
Browse files Browse the repository at this point in the history
* make build specification optional

Co-authored-by: Karl DeBisschop <karl.debisschop@bioraft.com>
  • Loading branch information
kdebisschop and Karl DeBisschop authored Mar 9, 2022
1 parent c52bd1e commit af20c94
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:

steps:
- uses: actions/checkout@v1
- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Run unit tests
run: ./gradlew test
- name: Determine coverage
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ gradle.projectsEvaluated {
}

dependencies {
implementation 'org.rundeck:rundeck-core:3.2.0-20191218'
implementation 'org.rundeck:rundeck-core:3.+'

testImplementation group: 'junit', name: 'junit', version:'4.12'

Expand Down
12 changes: 9 additions & 3 deletions src/main/java/com/bioraft/rundeck/nexus/BranchOrVersion.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,15 @@ public String getVersion() {
public BranchOrVersion(String path) {
artifactId = component(path);
String tag = tag(path);
build = tag.replaceFirst("^.*" + BUILD_SEPARATOR_REGEX + "([a-zA-Z0-9]+)$", "$1");
versionOrBranch = tag.replaceFirst("^(.*)" + BUILD_SEPARATOR_REGEX + build + "$", "$1");
sep = tag.replaceFirst("^.*(" + BUILD_SEPARATOR_REGEX + ")" + build + "$", "$1");
if (tag.matches("^.+" + BUILD_SEPARATOR_REGEX + "[a-zA-Z0-9]+$")) {
build = tag.replaceFirst("^.+" + BUILD_SEPARATOR_REGEX + "([a-zA-Z0-9]+)$", "$1");
versionOrBranch = tag.replaceFirst("^(.+)" + BUILD_SEPARATOR_REGEX + build + "$", "$1");
sep = tag.replaceFirst("^.+(" + BUILD_SEPARATOR_REGEX + ")" + build + "$", "$1");
} else {
build = "";
versionOrBranch = tag;
sep = "";
}
this.parts = versionOrBranch.split("[.]");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,20 @@ public void returnsFourItemsForOneBranchAndTwoBareSemanticReleases() throws IOEx
assertEquals("COMP_NAME:14.2.3-4", options.get(3).getName());
}

@Test
public void handlesTagsWithoutBuildSpecifier() throws IOException {
when(client.newCall(any())).thenReturn(call);
String json = "{\"items\":[" + item("v141.1") + "," + item("rc141.1raft4711a") + "]}";
when(call.execute()).thenReturn(response(json));

Nexus3OptionProvider provider = new Nexus3OptionProvider(client);
List<OptionValue> options = provider.getOptionValues(configuration);

assertEquals(3, options.size());
assertEquals("COMP_NAME:rc141.1raft4711a", options.get(1).getName());
assertEquals("COMP_NAME:v141.1", options.get(0).getName());
}

@Test
public void sortsBuildNumbersNumerically() throws IOException {
when(client.newCall(any())).thenReturn(call);
Expand Down

0 comments on commit af20c94

Please sign in to comment.