Allow callers of ChangeInserter to suppress running hooks
Add a method to the ChangeInserter to allow callers to prevent hooks from being executed on the created change. Change-Id: I5a6d8f9c1d039ff43ee9529d15b57355cbd39ec5
This commit is contained in:
@@ -63,6 +63,7 @@ public class ChangeInserter {
|
||||
|
||||
private ChangeMessage changeMessage;
|
||||
private Set<Account.Id> reviewers;
|
||||
private boolean runHooks;
|
||||
|
||||
@Inject
|
||||
ChangeInserter(Provider<ReviewDb> dbProvider,
|
||||
@@ -84,8 +85,8 @@ public class ChangeInserter {
|
||||
this.refControl = refControl;
|
||||
this.change = change;
|
||||
this.commit = commit;
|
||||
|
||||
this.reviewers = Collections.emptySet();
|
||||
this.runHooks = true;
|
||||
|
||||
patchSet =
|
||||
new PatchSet(new PatchSet.Id(change.getId(), INITIAL_PATCH_SET_ID));
|
||||
@@ -113,6 +114,11 @@ public class ChangeInserter {
|
||||
return this;
|
||||
}
|
||||
|
||||
public ChangeInserter setRunHooks(boolean runHooks) {
|
||||
this.runHooks = runHooks;
|
||||
return this;
|
||||
}
|
||||
|
||||
public PatchSet getPatchSet() {
|
||||
return patchSet;
|
||||
}
|
||||
@@ -143,6 +149,8 @@ public class ChangeInserter {
|
||||
indexer.index(change);
|
||||
gitRefUpdated.fire(change.getProject(), patchSet.getRefName(),
|
||||
ObjectId.zeroId(), commit);
|
||||
hooks.doPatchsetCreatedHook(change, patchSet, db);
|
||||
if (runHooks) {
|
||||
hooks.doPatchsetCreatedHook(change, patchSet, db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user