Set subject for commits on note branch when change/ps is created

Instead of using the default subject for commits on the note branch
which is

  Update patch set XX

be more specific when a change / patch set is created:

  Create change / Create patch set XX

These messages are consistent with the ones that are set by
ChangeRebuilder.

Change-Id: I26a0154f92d55fe594d46be031047de27e37366c
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2016-01-20 10:04:46 +01:00
parent d94ef2a7de
commit 315005ddb0
5 changed files with 9 additions and 0 deletions

View File

@@ -897,6 +897,8 @@ public class ChangeIT extends AbstractDaemonTest {
repo.exactRef(ChangeNoteUtil.changeRefName(new Change.Id(c._number)))
.getObjectId());
assertThat(commitPatchSetCreation.getShortMessage())
.isEqualTo("Create patch set 2");
PersonIdent expectedAuthor = ChangeNoteUtil.newIdent(
accountCache.get(admin.id).getAccount(), c.updated,
serverIdent.get(), AnonymousCowardNameProvider.DEFAULT);
@@ -908,6 +910,8 @@ public class ChangeIT extends AbstractDaemonTest {
RevCommit commitChangeCreation =
rw.parseCommit(commitPatchSetCreation.getParent(0));
assertThat(commitChangeCreation.getShortMessage())
.isEqualTo("Create change");
expectedAuthor = ChangeNoteUtil.newIdent(
accountCache.get(admin.id).getAccount(), c.created, serverIdent.get(),
AnonymousCowardNameProvider.DEFAULT);

View File

@@ -113,6 +113,8 @@ public class CreateChangeIT extends AbstractDaemonTest {
repo.exactRef(ChangeNoteUtil.changeRefName(new Change.Id(c._number)))
.getObjectId());
assertThat(commit.getShortMessage()).isEqualTo("Create change");
PersonIdent expectedAuthor = ChangeNoteUtil.newIdent(
accountCache.get(admin.id).getAccount(), c.created, serverIdent.get(),
AnonymousCowardNameProvider.DEFAULT);

View File

@@ -292,6 +292,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
ctx.getChange().setCurrentPatchSet(patchSetInfo);
ChangeUpdate update = ctx.getUpdate(patchSet.getId());
update.setSubject("Create change");
update.setTopic(change.getTopic());
if (patchSet.getGroups() == null) {

View File

@@ -216,6 +216,7 @@ public class PatchSetInserter extends BatchUpdate.Op {
change = ctx.getChange();
ChangeUpdate update = ctx.getUpdate(psId);
update.setSubject("Create patch set " + psId.get());
if (!change.getStatus().isOpen() && !allowClosed) {
throw new InvalidChangeOperationException(String.format(

View File

@@ -2245,6 +2245,7 @@ public class ReceiveCommits {
Map<String, Short> approvals = new HashMap<>();
ChangeUpdate update = updateFactory.create(
changeCtl, newPatchSet.getCreatedOn());
update.setSubject("Create patch set " + newPatchSet.getId().get());
update.setPatchSetId(newPatchSet.getId());
if (magicBranch != null) {