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 ChangeMessage changeMessage;
|
||||||
private Set<Account.Id> reviewers;
|
private Set<Account.Id> reviewers;
|
||||||
|
private boolean runHooks;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ChangeInserter(Provider<ReviewDb> dbProvider,
|
ChangeInserter(Provider<ReviewDb> dbProvider,
|
||||||
@@ -84,8 +85,8 @@ public class ChangeInserter {
|
|||||||
this.refControl = refControl;
|
this.refControl = refControl;
|
||||||
this.change = change;
|
this.change = change;
|
||||||
this.commit = commit;
|
this.commit = commit;
|
||||||
|
|
||||||
this.reviewers = Collections.emptySet();
|
this.reviewers = Collections.emptySet();
|
||||||
|
this.runHooks = true;
|
||||||
|
|
||||||
patchSet =
|
patchSet =
|
||||||
new PatchSet(new PatchSet.Id(change.getId(), INITIAL_PATCH_SET_ID));
|
new PatchSet(new PatchSet.Id(change.getId(), INITIAL_PATCH_SET_ID));
|
||||||
@@ -113,6 +114,11 @@ public class ChangeInserter {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ChangeInserter setRunHooks(boolean runHooks) {
|
||||||
|
this.runHooks = runHooks;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public PatchSet getPatchSet() {
|
public PatchSet getPatchSet() {
|
||||||
return patchSet;
|
return patchSet;
|
||||||
}
|
}
|
||||||
@@ -143,6 +149,8 @@ public class ChangeInserter {
|
|||||||
indexer.index(change);
|
indexer.index(change);
|
||||||
gitRefUpdated.fire(change.getProject(), patchSet.getRefName(),
|
gitRefUpdated.fire(change.getProject(), patchSet.getRefName(),
|
||||||
ObjectId.zeroId(), commit);
|
ObjectId.zeroId(), commit);
|
||||||
|
if (runHooks) {
|
||||||
hooks.doPatchsetCreatedHook(change, patchSet, db);
|
hooks.doPatchsetCreatedHook(change, patchSet, db);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user