Class ApprovalCopier

java.lang.Object
com.google.gerrit.server.approval.ApprovalCopier

public class ApprovalCopier extends Object
Computes copied approvals for a given patch set.

Approvals are copied if:

  • the approval on the previous patch set matches the copy condition of its label
  • the approval is not overridden by a current approval on the patch set

Callers should store the copied approvals in NoteDb when a new patch set is created.

  • Method Details

    • forPatchSet

      public ApprovalCopier.Result forPatchSet(ChangeNotes notes, PatchSet ps, org.eclipse.jgit.revwalk.RevWalk rw, org.eclipse.jgit.lib.Config repoConfig)
      Returns all copied approvals that apply to the given patch set.

      Approvals are copied if:

      • the approval on the previous patch set matches the copy condition of its label
      • the approval is not overridden by a current approval on the patch set
    • forApproval

      public com.google.common.collect.ImmutableList<PatchSet.Id> forApproval(ChangeNotes changeNotes, PatchSet sourcePatchSet, Account.Id approverId, String label, short approvalValue) throws IOException
      Returns all follow-up patch sets of the given patch set to which the given approval is copyable.

      An approval is considered as copyable to a follow-up patch set if it matches the copy rules of the label and it is copyable to all intermediate follow-up patch sets as well.

      The returned follow-up patch sets are returned in the order of their patch set IDs.

      Note: This method only checks the copy rules to detect if the approval is copyable. There are other factors, not checked here, that can prevent the copying of the approval to the returned follow-up patch sets (e.g. if they already have a matching non-copy approval that prevents the copying).

      Parameters:
      changeNotes - the change notes
      sourcePatchSet - the patch set on which the approval was applied
      approverId - the account ID of the user that applied the approval
      label - the label of the approval that was applied
      approvalValue - the value of the approval that was applied
      Returns:
      the follow-up patch sets to which the approval is copyable, ordered by patch set ID
      Throws:
      IOException