Include merge result commit in change-merged stream-event
When CI gets a change merged event what the CI most likely wants to build is not the last patch set of the change but the result on the target branch. If the merge of a change was not fast forward these are two separate commits. With this change the CI can retrieve the merge result from the newRev of a change merged event. Change-Id: I1d61ab253f4028a26cfbf0427b33873c294ee29e
This commit is contained in:
committed by
David Pursehouse
parent
959aec4d3e
commit
9686cf224b
@@ -446,14 +446,16 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doChangeMergedHook(final Change change, final Account account,
|
||||
final PatchSet patchSet, final ReviewDb db) throws OrmException {
|
||||
public void doChangeMergedHook(final Change change, final Account account,
|
||||
final PatchSet patchSet, final ReviewDb db, String mergeResultRev)
|
||||
throws OrmException {
|
||||
final ChangeMergedEvent event = new ChangeMergedEvent();
|
||||
final AccountState owner = accountCache.get(change.getOwner());
|
||||
|
||||
event.change = eventFactory.asChangeAttribute(change);
|
||||
event.submitter = eventFactory.asAccountAttribute(account);
|
||||
event.patchSet = eventFactory.asPatchSetAttribute(patchSet);
|
||||
event.newRev = mergeResultRev;
|
||||
fireEvent(change, event, db);
|
||||
|
||||
final List<String> args = new ArrayList<>();
|
||||
@@ -465,6 +467,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
addArg(args, "--topic", event.change.topic);
|
||||
addArg(args, "--submitter", getDisplayName(account));
|
||||
addArg(args, "--commit", event.patchSet.revision);
|
||||
addArg(args, "--newrev", mergeResultRev);
|
||||
|
||||
runHook(change.getProject(), changeMergedHook, args);
|
||||
}
|
||||
|
||||
@@ -79,10 +79,11 @@ public interface ChangeHooks {
|
||||
* @param change The change itself.
|
||||
* @param account The gerrit user who submitted the change.
|
||||
* @param patchSet The patchset that was merged.
|
||||
* @param mergeResultRev The SHA-1 of the merge result revision.
|
||||
* @throws OrmException
|
||||
*/
|
||||
public void doChangeMergedHook(Change change, Account account,
|
||||
PatchSet patchSet, ReviewDb db) throws OrmException;
|
||||
PatchSet patchSet, ReviewDb db, String mergeResultRev) throws OrmException;
|
||||
|
||||
/**
|
||||
* Fire the Merge Failed Hook.
|
||||
|
||||
@@ -44,7 +44,7 @@ public final class DisabledChangeHooks implements ChangeHooks {
|
||||
|
||||
@Override
|
||||
public void doChangeMergedHook(Change change, Account account,
|
||||
PatchSet patchSet, ReviewDb db) {
|
||||
PatchSet patchSet, ReviewDb db, String mergeResultRev) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user