Move doRefUpdatedHook to validateForReceiveCommits

This means that doRefUpdatedHook() will be called for every commit pushed in chain
instead of once for the whole chain.  This is not ideal, and likely slow.  This
is being done in anticipation of moving hooks to a plugin, which requires making
them fire off of events.  There are already 2 validating event types for commits,
and we don't really want to make a third.  This at least allows it to run from a
plugin.

Change-Id: I5905c44c7df448a353263cbc0a79a48776cb0965
This commit is contained in:
Martin Fick
2015-11-11 16:26:08 -07:00
parent 35882c9b9f
commit 535cd5e0ac
2 changed files with 1 additions and 13 deletions

View File

@@ -897,19 +897,6 @@ public class ReceiveCommits {
continue;
}
HookResult result = hooks.doRefUpdateHook(project, cmd.getRefName(),
user.getAccount(), cmd.getOldId(),
cmd.getNewId());
if (result != null) {
final String message = result.toString().trim();
if (result.getExitValue() != 0) {
reject(cmd, message);
continue;
}
rp.sendMessage(message);
}
if (MagicBranch.isMagicBranch(cmd.getRefName())) {
parseMagicBranch(cmd);
continue;

View File

@@ -131,6 +131,7 @@ public class CommitValidators {
validators.add(new ConfigValidator(refControl, repo));
validators.add(new BannedCommitsValidator(rejectCommits));
validators.add(new PluginCommitValidationListener(commitValidationListeners));
validators.add(new ChangeHookValidator(refControl, hooks));
List<CommitValidationMessage> messages = new LinkedList<>();