diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java index 73850b788..d7e930831 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/BatchRefUpdate.java @@ -59,6 +59,7 @@ import java.util.List; import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.lib.RefUpdate.Result; import org.eclipse.jgit.revwalk.RevWalk; +import org.eclipse.jgit.transport.PushCertificate; import org.eclipse.jgit.transport.ReceiveCommand; /** @@ -85,6 +86,9 @@ public class BatchRefUpdate { /** Should the result value be appended to {@link #refLogMessage}. */ private boolean refLogIncludeResult; + /** Push certificate associated with this update. */ + private PushCertificate pushCert; + /** * Initialize a new batch update. * @@ -195,6 +199,33 @@ public class BatchRefUpdate { return refLogMessage == null; } + /** + * Set a push certificate associated with this update. + *

+ * This usually includes commands to update the refs in this batch, but is not + * required to. + * + * @param cert + * push certificate, may be null. + * @since 4.1 + */ + public void setPushCertificate(PushCertificate cert) { + pushCert = cert; + } + + /** + * Set the push certificate associated with this update. + *

+ * This usually includes commands to update the refs in this batch, but is not + * required to. + * + * @return push certificate, may be null. + * @since 4.1 + */ + protected PushCertificate getPushCertificate() { + return pushCert; + } + /** @return commands this update will process. */ public List getCommands() { return Collections.unmodifiableList(commands); @@ -377,6 +408,7 @@ public class BatchRefUpdate { ru.setRefLogIdent(refLogIdent); ru.setRefLogMessage(refLogMessage, refLogIncludeResult); } + ru.setPushCertificate(pushCert); switch (cmd.getType()) { case DELETE: if (!ObjectId.zeroId().equals(cmd.getOldId())) diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java index aeef9f074..4316cd0a1 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/lib/RefUpdate.java @@ -52,6 +52,7 @@ import org.eclipse.jgit.internal.JGitText; import org.eclipse.jgit.revwalk.RevCommit; import org.eclipse.jgit.revwalk.RevObject; import org.eclipse.jgit.revwalk.RevWalk; +import org.eclipse.jgit.transport.PushCertificate; /** * Creates, updates or deletes any reference. @@ -165,6 +166,9 @@ public abstract class RefUpdate { /** Result of the update operation. */ private Result result = Result.NOT_ATTEMPTED; + /** Push certificate associated with this update. */ + private PushCertificate pushCert; + private final Ref ref; /** @@ -413,6 +417,31 @@ public abstract class RefUpdate { oldValue = old; } + /** + * Set a push certificate associated with this update. + *

+ * This usually includes a command to update this ref, but is not required to. + * + * @param cert + * push certificate, may be null. + * @since 4.1 + */ + public void setPushCertificate(PushCertificate cert) { + pushCert = cert; + } + + /** + * Set the push certificate associated with this update. + *

+ * This usually includes a command to update this ref, but is not required to. + * + * @return push certificate, may be null. + * @since 4.1 + */ + protected PushCertificate getPushCertificate() { + return pushCert; + } + /** * Get the status of this update. *

diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java index b687bb2d7..54eb747e9 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/transport/BaseReceivePack.java @@ -1479,6 +1479,7 @@ public abstract class BaseReceivePack { batch.setRefLogMessage("push", true); //$NON-NLS-1$ batch.addCommand(toApply); try { + batch.setPushCertificate(getPushCertificate()); batch.execute(walk, updating); } catch (IOException err) { for (ReceiveCommand cmd : toApply) {