Include latest approved patch-set on submit

The change message and email should include the latest approved
patch-set.

Change-Id: Ifef82bab9263f1bff89d478813f25b59227e1f03
This commit is contained in:
Gal Paikin
2021-02-01 21:36:26 +01:00
parent 9e6ea7b77e
commit a9b3de8d74
2 changed files with 22 additions and 2 deletions

View File

@@ -88,7 +88,8 @@ public class SubmitWithStickyApprovalDiff {
return "";
}
String diff =
"\n\nThe change was submitted with unreviewed changes in the following files:\n\n";
String.format("\n\n%d is the latest approved patch-set.\n", latestApprovedPatchsetId.get());
diff += "The change was submitted with unreviewed changes in the following files:\n\n";
PatchList patchList =
getPatchList(
notes.getProjectName(),

View File

@@ -251,6 +251,24 @@ public class SubmitWithStickyApprovalDiffIT extends AbstractDaemonTest {
.isEqualTo("Change has been successfully merged");
}
@Test
public void diffChangeMessageOnSubmitWithStickyVote_approvedPatchset() throws Exception {
Change.Id changeId = changeOperations.newChange().project(project).create();
changeOperations.change(changeId).newPatchset().create();
// approve patch-set 2
gApi.changes().id(changeId.get()).current().review(ReviewInput.approve());
// create patch-set 3
changeOperations.change(changeId).newPatchset().create();
gApi.changes().id(changeId.get()).current().submit();
// patch-set 2 was the latest approved one.
assertThat(Iterables.getLast(gApi.changes().id(changeId.get()).messages()).message)
.contains("2 is the latest approved patch-set.");
}
private void assertDiffChangeMessageAndEmailWithStickyApproval(
String message,
String file,
@@ -261,7 +279,8 @@ public class SubmitWithStickyApprovalDiffIT extends AbstractDaemonTest {
List<String> newLines,
String oldFileName) {
String expectedMessage =
"The change was submitted with unreviewed changes in the following files:\n"
"1 is the latest approved patch-set.\n"
+ "The change was submitted with unreviewed changes in the following files:\n"
+ "\n"
+ String.format("The name of the file: %s\n", file)
+ String.format("Insertions: %d, Deletions: %d.\n\n", insertions, deletions);