ReceiveCommits: Set push certificate on patch sets

Bug: Issue 4262
Change-Id: Ifb1145c7ae637a9e8d6b33c0019fdc0bc2d3d845
This commit is contained in:
David Pursehouse
2016-07-27 09:38:40 +09:00
parent cc16797b3c
commit 0135b50354
2 changed files with 9 additions and 1 deletions

View File

@@ -124,6 +124,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
private ChangeMessage changeMessage;
private PatchSetInfo patchSetInfo;
private PatchSet patchSet;
private String pushCert;
@Inject
ChangeInserter(ProjectControl.GenericFactory projectControlFactory,
@@ -275,6 +276,10 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
updateRefCommand = cmd;
}
public void setPushCertificate(String cert) {
pushCert = cert;
}
public PatchSet getPatchSet() {
checkState(patchSet != null,
"getPatchSet() only valid after creating change");
@@ -335,7 +340,7 @@ public class ChangeInserter extends BatchUpdate.InsertChangeOp {
newGroups = GroupCollector.getDefaultGroups(commit);
}
patchSet = psUtil.insert(ctx.getDb(), ctx.getRevWalk(), update, psId,
commit, draft, newGroups, null);
commit, draft, newGroups, pushCert);
/* TODO: fixStatus is used here because the tests
* (byStatusClosed() in AbstractQueryChangesTest)

View File

@@ -1785,6 +1785,9 @@ public class ReceiveCommits {
cmd = new ReceiveCommand(ObjectId.zeroId(), commit,
ins.getPatchSetId().toRefName());
ins.setUpdateRefCommand(cmd);
if (rp.getPushCertificate() != null) {
ins.setPushCertificate(rp.getPushCertificate().toTextWithSignature());
}
}
private void addOps(BatchUpdate bu) throws RestApiException {