Fixed milestone closing

without this change when tag was equal to e.g. 1.2.3.RELEASE and milestone 1.2.3 the latter wasn't closed.
with this change we also check the numeric equality of version and tag
This commit is contained in:
Marcin Grzejszczak
2017-04-19 11:11:35 +02:00
parent 0ffa75c0ee
commit 949cc081af
2 changed files with 27 additions and 1 deletions

View File

@@ -49,7 +49,8 @@ class MilestoneCloser {
for (Milestone milestone : milestones) {
Milestone.Smart smartMilestone = new Milestone.Smart(milestone);
try {
if (tagVersion.equals(milestoneTitle(smartMilestone))) {
String title = milestoneTitle(smartMilestone);
if (tagVersion.equals(title) || numericVersion(tagVersion).equals(title)) {
log.info("Found a matching milestone - closing it");
smartMilestone.close();
matchingMilestone = true;
@@ -65,6 +66,10 @@ class MilestoneCloser {
}
}
private String numericVersion(String version) {
return version.substring(0, version.lastIndexOf("."));
}
String milestoneTitle(Milestone.Smart milestone) throws IOException {
return milestone.title();
}

View File

@@ -48,6 +48,27 @@ public class MilestoneCloserTests {
repo.milestones().create("0.2.0.BUILD-SNAPSHOT");
closer.closeMilestone(sleuthProject());
then(this.capture.toString()).doesNotContain("No matching milestone was found");
}
@Test
public void should_close_milestone_when_the_milestone_contains_numeric_version_only() throws IOException {
MilestoneCloser closer = new MilestoneCloser(this.github, withToken()) {
@Override String org() {
return repo.coordinates().user();
}
@Override String milestoneTitle(Milestone.Smart milestone)
throws IOException {
return "0.2.0";
}
};
repo.milestones().create("0.2.0");
closer.closeMilestone(sleuthProject());
then(this.capture.toString()).doesNotContain("No matching milestone was found");
}
private ProjectVersion sleuthProject() {