Add event hook support
The following hooks are defined and implemented: * patchset-created --change <change id> --project <project name> --branch <branch> --commit <sha1> --patchset <patchset id> * comment-added --change <change id> --project <project name> --branch <branch> --author <comment author> --comment <comment> [--<approval category id> <score> --<approval category id> <score> ...] * change-merged --change <change id> --project <project name> --branch <branch> --submitter <submitter> --commit <sha1> * change-abandoned --change <change id> --project <project name> --branch <branch> --abandoner <abandoner> --reason <reason> Bug: issue 368 Bug: issue 383 Change-Id: Ic2f041a71c744d0938d79b1106c9119d6318731a Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:

committed by
Shawn O. Pearce

parent
48bc519a98
commit
6c2b677980
@@ -14,6 +14,7 @@
|
||||
|
||||
package com.google.gerrit.sshd.commands;
|
||||
|
||||
import com.google.gerrit.common.ChangeHookRunner;
|
||||
import static com.google.gerrit.reviewdb.ApprovalCategory.PUSH_HEAD;
|
||||
import static com.google.gerrit.reviewdb.ApprovalCategory.PUSH_HEAD_REPLACE;
|
||||
import static com.google.gerrit.reviewdb.ApprovalCategory.PUSH_HEAD_UPDATE;
|
||||
@@ -153,6 +154,9 @@ final class Receive extends AbstractGitCommand {
|
||||
@Inject
|
||||
private PatchSetInfoFactory patchSetInfoFactory;
|
||||
|
||||
@Inject
|
||||
private ChangeHookRunner hooks;
|
||||
|
||||
@Inject
|
||||
@CanonicalWebUrl
|
||||
@Nullable
|
||||
@@ -870,6 +874,8 @@ final class Receive extends AbstractGitCommand {
|
||||
} catch (EmailException e) {
|
||||
log.error("Cannot send email for new change " + change.getId(), e);
|
||||
}
|
||||
|
||||
hooks.doPatchsetCreatedHook(change, ps);
|
||||
}
|
||||
|
||||
private static boolean isReviewer(final FooterLine candidateFooterLine) {
|
||||
@@ -1132,6 +1138,8 @@ final class Receive extends AbstractGitCommand {
|
||||
insertDummyApproval(result, reviewer, catId, db);
|
||||
}
|
||||
}
|
||||
|
||||
hooks.doPatchsetCreatedHook(result.change, ps);
|
||||
}
|
||||
|
||||
final RefUpdate ru = repo.updateRef(ps.getRefName());
|
||||
@@ -1447,6 +1455,8 @@ final class Receive extends AbstractGitCommand {
|
||||
final PatchSet.Id psi = result.patchSet.getId();
|
||||
log.error("Cannot send email for submitted patch set " + psi, e);
|
||||
}
|
||||
|
||||
hooks.doChangeMergedHook(result.change, currentUser.getAccount(), result.patchSet);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user