Include a magic /MERGE_LIST file for merge commits
The /MERGE_LIST file is generated by Gerrit and is automatically included in all changes for merge commits. It contains a list with the commits that are integrated by accepting the merge commit. When comparing against the auto-merge or a previous patch set it is assumed that the first parent is uninteresting, so that the file lists all commits which are reachable by the other parents, but not by the first parent. If a comparison against a selected parent is done, that parent is marked as uninteresting. This means the content of the file depends on the selection in 'Diff Against' drop-down box. By having the /MERGE_LIST file reviewers can immediately see which commits get integrated by this merge commit. This is important since for merge commits reviewers are supposed to review and approve these commits. Having a file for this allow reviewers to comment on the list and also see diffs between patch sets. In edit mode the /MERGE_LIST file is not editable. Change-Id: Iafcfe3f274ed334e9a40c13de5040a7509389e27 Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
@@ -17,6 +17,8 @@ package com.google.gerrit.acceptance;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
import static com.google.gerrit.acceptance.GitUtil.initSsh;
|
||||
import static com.google.gerrit.extensions.api.changes.SubmittedTogetherOption.NON_VISIBLE_CHANGES;
|
||||
import static com.google.gerrit.reviewdb.client.Patch.COMMIT_MSG;
|
||||
import static com.google.gerrit.reviewdb.client.Patch.MERGE_LIST;
|
||||
import static com.google.gerrit.server.group.SystemGroupBackend.REGISTERED_USERS;
|
||||
import static org.eclipse.jgit.lib.Constants.HEAD;
|
||||
|
||||
@@ -49,6 +51,8 @@ import com.google.gerrit.extensions.client.ListChangesOption;
|
||||
import com.google.gerrit.extensions.client.SubmitType;
|
||||
import com.google.gerrit.extensions.common.ActionInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeInfo;
|
||||
import com.google.gerrit.extensions.common.ChangeType;
|
||||
import com.google.gerrit.extensions.common.DiffInfo;
|
||||
import com.google.gerrit.extensions.common.EditInfo;
|
||||
import com.google.gerrit.extensions.restapi.BinaryResult;
|
||||
import com.google.gerrit.extensions.restapi.IdString;
|
||||
@@ -68,6 +72,7 @@ import com.google.gerrit.server.account.AccountCache;
|
||||
import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.gerrit.server.change.Abandon;
|
||||
import com.google.gerrit.server.change.ChangeResource;
|
||||
import com.google.gerrit.server.change.FileContentUtil;
|
||||
import com.google.gerrit.server.change.RevisionResource;
|
||||
import com.google.gerrit.server.change.Revisions;
|
||||
import com.google.gerrit.server.config.AllProjectsName;
|
||||
@@ -1098,4 +1103,45 @@ public abstract class AbstractDaemonTest {
|
||||
}
|
||||
assertThat(refValues.keySet()).containsAnyIn(trees.keySet());
|
||||
}
|
||||
|
||||
protected void assertDiffForNewFile(DiffInfo diff, RevCommit commit,
|
||||
String path, String expectedContentSideB) throws Exception {
|
||||
List<String> expectedLines = new ArrayList<>();
|
||||
for (String line : expectedContentSideB.split("\n")) {
|
||||
expectedLines.add(line);
|
||||
}
|
||||
|
||||
assertThat(diff.binary).isNull();
|
||||
assertThat(diff.changeType).isEqualTo(ChangeType.ADDED);
|
||||
assertThat(diff.diffHeader).isNotNull();
|
||||
assertThat(diff.intralineStatus).isNull();
|
||||
assertThat(diff.webLinks).isNull();
|
||||
|
||||
assertThat(diff.metaA).isNull();
|
||||
assertThat(diff.metaB).isNotNull();
|
||||
assertThat(diff.metaB.commitId).isEqualTo(commit.name());
|
||||
|
||||
String expectedContentType = "text/plain";
|
||||
if (COMMIT_MSG.equals(path)) {
|
||||
expectedContentType = FileContentUtil.TEXT_X_GERRIT_COMMIT_MESSAGE;
|
||||
} else if (MERGE_LIST.equals(path)) {
|
||||
expectedContentType = FileContentUtil.TEXT_X_GERRIT_MERGE_LIST;
|
||||
}
|
||||
assertThat(diff.metaB.contentType).isEqualTo(expectedContentType);
|
||||
|
||||
assertThat(diff.metaB.lines).isEqualTo(expectedLines.size());
|
||||
assertThat(diff.metaB.name).isEqualTo(path);
|
||||
assertThat(diff.metaB.webLinks).isNull();
|
||||
|
||||
assertThat(diff.content).hasSize(1);
|
||||
DiffInfo.ContentEntry contentEntry = diff.content.get(0);
|
||||
assertThat(contentEntry.b).containsExactlyElementsIn(expectedLines)
|
||||
.inOrder();
|
||||
assertThat(contentEntry.a).isNull();
|
||||
assertThat(contentEntry.ab).isNull();
|
||||
assertThat(contentEntry.common).isNull();
|
||||
assertThat(contentEntry.editA).isNull();
|
||||
assertThat(contentEntry.editB).isNull();
|
||||
assertThat(contentEntry.skip).isNull();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user