Skip to content
Permalink
Browse files
update-sync labels should be applied to all-bar-one records
Reviewed-by: rwestberg, kcr
  • Loading branch information
Rob McKenna authored and rwestberg committed Sep 30, 2020
1 parent 606b40c commit f023a346143b1c189dc52078d4dd00e227f4da1a
Showing 2 changed files with 34 additions and 8 deletions.
@@ -313,13 +313,12 @@ static void labelReleaseStreamDuplicates(Issue issue, String label) {
allIssues.addAll(related);

for (var streamIssues : groupByReleaseStream(allIssues)) {
// First entry should not have the label
var first = streamIssues.get(0);
if (first.labels().contains(label)) {
first.removeLabel(label);
}

// But all the following ones should
// The first issue may have the label if it was part of another
// stream. (e.g. feature release has 14 & 15 where update release
// has 15, 15.0.1 & 15.0.2. In this case the label should be
// applied to 15, which is the first releases in the 15u stream)
// This means we ignore the first issue for the purposes of adding
// the label.
if (streamIssues.size() > 1) {
var rest = streamIssues.subList(1, streamIssues.size());
for (var i : rest) {
@@ -212,6 +212,20 @@ void assertLabeled(String... labeledVersions) {
}
assertEquals(labels, labeledIssues);
}

void assertNotLabeled(String... labeledVersions) {
Backports.labelReleaseStreamDuplicates(issues.get(0), "hgupdate-sync");

var labels = new HashSet<>(Arrays.asList(labeledVersions));
var unLabeledIssues = new HashSet<String>();
for (var issue : issues) {
var version = issue.properties().get("fixVersions").get(0).asString();
if (!issue.labels().contains("hgupdate-sync")) {
unLabeledIssues.add(version);
}
}
assertEquals(labels, unLabeledIssues);
}
}

@Test
@@ -246,7 +260,7 @@ void labelUpdateReleaseStream(TestInfo testInfo) throws IOException {
backports.assertLabeled("14.0.1", "14.0.2");

backports.addBackports("15", "15.0.1", "15.0.2");
backports.assertLabeled("14.0.1", "14.0.2", "15.0.1", "15.0.2");
backports.assertLabeled("14.0.1", "14.0.2", "15", "15.0.1", "15.0.2");
}
}

@@ -264,6 +278,19 @@ void labelOpenJdkUpdateReleaseStream(TestInfo testInfo) throws IOException {
}
}

@Test
void labelSeparateOpenJdkUpdateReleaseStream(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {
var backports = new BackportManager(credentials, "11.0.3");
backports.assertLabeled();

backports.addBackports("11.0.3-oracle", "11.0.4", "11.0.4-oracle");
backports.assertLabeled("11.0.4", "11.0.4-oracle");
backports.assertNotLabeled("11.0.3-oracle", "11.0.3");
}
}


@Test
void labelBprStream8(TestInfo testInfo) throws IOException {
try (var credentials = new HostCredentials(testInfo)) {

1 comment on commit f023a34

@bridgekeeper
Copy link

@bridgekeeper bridgekeeper bot commented on f023a34 Sep 30, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.