CreateAccessChange: Use same first ChangeMessage as elsewhere

Change-Id: Ie7e7bc7cd147c7ac6728f6a40eadce4853fc5cda
This commit is contained in:
Dave Borowitz 2017-09-13 13:46:10 -04:00
parent 451d7e8ed2
commit ad360af4bb
2 changed files with 14 additions and 3 deletions

View File

@ -14,6 +14,8 @@
package com.google.gerrit.acceptance.rest.project;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.gerrit.extensions.client.ListChangesOption.MESSAGES;
import static org.junit.Assert.fail;
import com.google.gerrit.acceptance.AbstractDaemonTest;
@ -119,6 +121,9 @@ public class AccessIT extends AbstractDaemonTest {
setApiUser(admin);
ChangeInfo c = gApi.changes().id(out._number).get(MESSAGES);
assertThat(c.messages.stream().map(m -> m.message)).containsExactly("Uploaded patch set 1");
ReviewInput reviewIn = new ReviewInput();
reviewIn.label("Code-Review", (short) 2);
gApi.changes().id(out._number).current().review(reviewIn);

View File

@ -14,6 +14,7 @@
package com.google.gerrit.server.project;
import com.google.common.collect.ImmutableMap;
import com.google.gerrit.common.TimeUtil;
import com.google.gerrit.common.data.AccessSection;
import com.google.gerrit.common.errors.InvalidNameException;
@ -29,6 +30,7 @@ import com.google.gerrit.reviewdb.client.PatchSet;
import com.google.gerrit.reviewdb.client.Project;
import com.google.gerrit.reviewdb.client.RefNames;
import com.google.gerrit.reviewdb.server.ReviewDb;
import com.google.gerrit.server.ApprovalsUtil;
import com.google.gerrit.server.Sequences;
import com.google.gerrit.server.change.ChangeInserter;
import com.google.gerrit.server.change.ChangeJson;
@ -149,8 +151,12 @@ public class CreateAccessChange implements RestModifyView<ProjectResource, Proje
// ProjectConfig doesn't currently support fusing into a BatchUpdate.
@SuppressWarnings("deprecation")
private ChangeInserter newInserter(Change.Id changeId, RevCommit commit) {
ChangeInserter ins = changeInserterFactory.create(changeId, commit, RefNames.REFS_CONFIG);
ins.setMessage("First patchset").setValidate(false).setUpdateRef(false);
return ins;
return changeInserterFactory
.create(changeId, commit, RefNames.REFS_CONFIG)
.setMessage(
// Same message as in ReceiveCommits.CreateRequest.
ApprovalsUtil.renderMessageWithApprovals(1, ImmutableMap.of(), ImmutableMap.of()))
.setValidate(false)
.setUpdateRef(false);
}
}