Merge "Set patchSet field for abandon and restore events"
This commit is contained in:
commit
dbebd950db
@ -90,7 +90,7 @@ change-abandoned
|
||||
Called whenever a change has been abandoned.
|
||||
|
||||
====
|
||||
change-abandoned --change <change id> --change-url <change url> --project <project name> --branch <branch> --topic <topic> --abandoner <abandoner> --reason <reason>
|
||||
change-abandoned --change <change id> --change-url <change url> --project <project name> --branch <branch> --topic <topic> --abandoner <abandoner> --commit <sha1> --reason <reason>
|
||||
====
|
||||
|
||||
change-restored
|
||||
@ -99,7 +99,7 @@ change-restored
|
||||
Called whenever a change has been restored.
|
||||
|
||||
====
|
||||
change-restored --change <change id> --change-url <change url> --project <project name> --branch <branch> --topic <topic> --restorer <restorer> --reason <reason>
|
||||
change-restored --change <change id> --change-url <change url> --project <project name> --branch <branch> --topic <topic> --restorer <restorer> --commit <sha1> --reason <reason>
|
||||
====
|
||||
|
||||
ref-updated
|
||||
|
@ -469,11 +469,13 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
}
|
||||
|
||||
public void doChangeAbandonedHook(final Change change, final Account account,
|
||||
final String reason, final ReviewDb db) throws OrmException {
|
||||
final PatchSet patchSet, final String reason, final ReviewDb db)
|
||||
throws OrmException {
|
||||
final ChangeAbandonedEvent event = new ChangeAbandonedEvent();
|
||||
|
||||
event.change = eventFactory.asChangeAttribute(change);
|
||||
event.abandoner = eventFactory.asAccountAttribute(account);
|
||||
event.patchSet = eventFactory.asPatchSetAttribute(patchSet);
|
||||
event.reason = reason;
|
||||
fireEvent(change, event, db);
|
||||
|
||||
@ -484,17 +486,20 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
addArg(args, "--branch", event.change.branch);
|
||||
addArg(args, "--topic", event.change.topic);
|
||||
addArg(args, "--abandoner", getDisplayName(account));
|
||||
addArg(args, "--commit", event.patchSet.revision);
|
||||
addArg(args, "--reason", reason == null ? "" : reason);
|
||||
|
||||
runHook(change.getProject(), changeAbandonedHook, args);
|
||||
}
|
||||
|
||||
public void doChangeRestoredHook(final Change change, final Account account,
|
||||
final String reason, final ReviewDb db) throws OrmException {
|
||||
final PatchSet patchSet, final String reason, final ReviewDb db)
|
||||
throws OrmException {
|
||||
final ChangeRestoredEvent event = new ChangeRestoredEvent();
|
||||
|
||||
event.change = eventFactory.asChangeAttribute(change);
|
||||
event.restorer = eventFactory.asAccountAttribute(account);
|
||||
event.patchSet = eventFactory.asPatchSetAttribute(patchSet);
|
||||
event.reason = reason;
|
||||
fireEvent(change, event, db);
|
||||
|
||||
@ -505,6 +510,7 @@ public class ChangeHookRunner implements ChangeHooks, LifecycleListener {
|
||||
addArg(args, "--branch", event.change.branch);
|
||||
addArg(args, "--topic", event.change.topic);
|
||||
addArg(args, "--restorer", getDisplayName(account));
|
||||
addArg(args, "--commit", event.patchSet.revision);
|
||||
addArg(args, "--reason", reason == null ? "" : reason);
|
||||
|
||||
runHook(change.getProject(), changeRestoredHook, args);
|
||||
|
@ -103,7 +103,7 @@ public interface ChangeHooks {
|
||||
* @throws OrmException
|
||||
*/
|
||||
public void doChangeAbandonedHook(Change change, Account account,
|
||||
String reason, ReviewDb db) throws OrmException;
|
||||
PatchSet patchSet, String reason, ReviewDb db) throws OrmException;
|
||||
|
||||
/**
|
||||
* Fire the Change Restored Hook.
|
||||
@ -114,7 +114,7 @@ public interface ChangeHooks {
|
||||
* @throws OrmException
|
||||
*/
|
||||
public void doChangeRestoredHook(Change change, Account account,
|
||||
String reason, ReviewDb db) throws OrmException;
|
||||
PatchSet patchSet, String reason, ReviewDb db) throws OrmException;
|
||||
|
||||
/**
|
||||
* Fire the Ref Updated Hook
|
||||
|
@ -37,7 +37,7 @@ public final class DisabledChangeHooks implements ChangeHooks {
|
||||
|
||||
@Override
|
||||
public void doChangeAbandonedHook(Change change, Account account,
|
||||
String reason, ReviewDb db) {
|
||||
PatchSet patchSet, String reason, ReviewDb db) {
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -52,7 +52,7 @@ public final class DisabledChangeHooks implements ChangeHooks {
|
||||
|
||||
@Override
|
||||
public void doChangeRestoredHook(Change change, Account account,
|
||||
String reason, ReviewDb db) {
|
||||
PatchSet patchSet, String reason, ReviewDb db) {
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -122,6 +122,7 @@ public class Abandon implements RestModifyView<ChangeResource, Input> {
|
||||
}
|
||||
hooks.doChangeAbandonedHook(change,
|
||||
caller.getAccount(),
|
||||
db.patchSets().get(change.currentPatchSetId()),
|
||||
Strings.emptyToNull(input.message),
|
||||
db);
|
||||
return json.format(change);
|
||||
|
@ -121,6 +121,7 @@ public class Restore implements RestModifyView<ChangeResource, Input> {
|
||||
}
|
||||
hooks.doChangeRestoredHook(change,
|
||||
caller.getAccount(),
|
||||
db.patchSets().get(change.currentPatchSetId()),
|
||||
Strings.emptyToNull(input.message),
|
||||
dbProvider.get());
|
||||
return json.format(change);
|
||||
|
Loading…
x
Reference in New Issue
Block a user