Merge branch 'stable-2.14' into stable-2.15
* stable-2.14:
Wrap account ID in quotes
Change-Id: I039658735bd1ef4e90c2a4c1be67a3a63c7f6fde
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/AgreementSignup.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/AgreementSignup.java
index 3953bf6..0eb9b6f 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/AgreementSignup.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/AgreementSignup.java
@@ -21,7 +21,7 @@
@Singleton
class AgreementSignup implements AgreementSignupListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -40,7 +40,7 @@
args.add("--user-id", submitter._accountId);
args.add("--cla-name", event.getAgreementName());
- hook.submit(args);
+ hook.execute(args);
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/AsynchronousHook.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/AsynchronousHook.java
index c581642..4e74ece 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/AsynchronousHook.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/AsynchronousHook.java
@@ -16,7 +16,7 @@
import java.nio.file.Path;
-public class AsynchronousHook extends Hook {
+class AsynchronousHook extends Hook {
private final HookQueue queue;
AsynchronousHook(HookQueue queue, Path path) {
@@ -24,11 +24,15 @@
this.queue = queue;
}
- void submit(HookArgs args) {
+ @Override
+ HookResult execute(HookArgs args) {
queue.submit(path, args);
+ return null;
}
- void submit(String projectName, HookArgs args) {
+ @Override
+ HookResult execute(String projectName, HookArgs args) {
queue.submit(projectName, path, args);
+ return null;
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeAbandoned.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeAbandoned.java
index 19e6753..20ace66 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeAbandoned.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeAbandoned.java
@@ -21,7 +21,7 @@
@Singleton
class ChangeAbandoned implements ChangeAbandonedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -45,6 +45,6 @@
args.add("--commit", c.currentRevision);
args.add("--reason", event.getReason());
- hook.submit(c.project, args);
+ hook.execute(c.project, args);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeMerged.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeMerged.java
index 6e28143..6ef03e0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeMerged.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeMerged.java
@@ -21,7 +21,7 @@
@Singleton
class ChangeMerged implements ChangeMergedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -45,6 +45,6 @@
args.add("--commit", c.currentRevision);
args.add("--newrev", event.getNewRevisionId());
- hook.submit(c.project, args);
+ hook.execute(c.project, args);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeRestored.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeRestored.java
index af0f9a8..27b1c07 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeRestored.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeRestored.java
@@ -21,7 +21,7 @@
@Singleton
class ChangeRestored implements ChangeRestoredListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -45,6 +45,6 @@
args.add("--commit", c.currentRevision);
args.add("--reason", event.getReason());
- hook.submit(c.project, args);
+ hook.execute(c.project, args);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/CommentAdded.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/CommentAdded.java
index cea65d1..7dc1624 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/CommentAdded.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/CommentAdded.java
@@ -21,7 +21,7 @@
@Singleton
class CommentAdded implements CommentAddedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -36,7 +36,6 @@
ChangeInfo c = event.getChange();
args.add("--change", c.id);
- args.add("--is-draft", event.getRevision().draft);
args.addUrl(c);
args.add("--change-owner", c.owner);
args.add("--project", c.project);
@@ -47,6 +46,6 @@
args.add("--comment", event.getComment());
args.addApprovals(event.getApprovals(), event.getOldApprovals());
- hook.submit(c.project, args);
+ hook.execute(c.project, args);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/CommitReceived.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/CommitReceived.java
index 02800fc..73b5ff5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/CommitReceived.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/CommitReceived.java
@@ -25,7 +25,7 @@
import org.eclipse.jgit.lib.ObjectId;
public class CommitReceived implements CommitValidationListener {
- private final SynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -49,11 +49,12 @@
args.add("--project", projectName);
args.add("--refname", refname);
args.add("--uploader", receiveEvent.user.getNameEmail());
+ args.add("--uploader-username", receiveEvent.user.getUserName());
args.add("--oldrev", old.name());
args.add("--newrev", receiveEvent.commit.name());
args.add("--cmdref", commandRef);
- HookResult result = hook.run(projectName, args);
+ HookResult result = hook.execute(projectName, args);
if (result != null) {
String output = result.toString();
if (result.getExitValue() != 0) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/DraftPublished.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/DraftPublished.java
deleted file mode 100644
index 7ae68f2..0000000
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/DraftPublished.java
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2016 The Android Open Source Project
-//
-// Licensed under the Apache License, Version 2.0 (the "License");
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-// http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an "AS IS" BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-
-package com.googlesource.gerrit.plugins.hooks;
-
-import com.google.gerrit.extensions.common.ChangeInfo;
-import com.google.gerrit.extensions.events.DraftPublishedListener;
-import com.google.inject.Inject;
-import com.google.inject.Singleton;
-
-@Singleton
-class DraftPublished implements DraftPublishedListener {
- private final AsynchronousHook hook;
- private final HookFactory hookFactory;
-
- @Inject
- DraftPublished(HookFactory hookFactory) {
- this.hook = hookFactory.createAsync("draftPublishedHook", "draft-published");
- this.hookFactory = hookFactory;
- }
-
- @Override
- public void onDraftPublished(DraftPublishedListener.Event event) {
- HookArgs args = hookFactory.createArgs();
-
- ChangeInfo c = event.getChange();
- args.add("--change", c.id);
- args.addUrl(c);
- args.add("--change-owner", c.owner);
- args.add("--project", c.project);
- args.add("--branch", c.branch);
- args.add("--topic", c.topic);
- args.add("--uploader", event.getWho());
- args.add("--commit", event.getRevision().commit.commit);
- args.add("--patchset", event.getRevision()._number);
-
- hook.submit(c.project, args);
- }
-}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/GitReferenceUpdated.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/GitReferenceUpdated.java
index cf1a10d..07fff1e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/GitReferenceUpdated.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/GitReferenceUpdated.java
@@ -20,7 +20,7 @@
@Singleton
class GitReferenceUpdated implements GitReferenceUpdatedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -39,6 +39,6 @@
args.add("--project", event.getProjectName());
args.add("--submitter", event.getUpdater());
- hook.submit(event.getProjectName(), args);
+ hook.execute(event.getProjectName(), args);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/HashtagsEdited.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/HashtagsEdited.java
index 9bb40c1..7735b38 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HashtagsEdited.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HashtagsEdited.java
@@ -22,7 +22,7 @@
@Singleton
class HashtagsEdited implements HashtagsEditedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -45,7 +45,7 @@
add(args, "--added", event.getAddedHashtags());
add(args, "--removed", event.getRemovedHashtags());
- hook.submit(c.project, args);
+ hook.execute(c.project, args);
}
private void add(HookArgs args, String name, Collection<String> hashtags) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/Hook.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/Hook.java
index 87fb4f4..fc84b9e 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/Hook.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/Hook.java
@@ -14,12 +14,17 @@
package com.googlesource.gerrit.plugins.hooks;
+import com.google.gerrit.common.Nullable;
import java.nio.file.Path;
-public class Hook {
+abstract class Hook {
protected final Path path;
Hook(Path path) {
this.path = path;
}
+
+ abstract @Nullable HookResult execute(HookArgs args);
+
+ abstract @Nullable HookResult execute(String projectName, HookArgs args);
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookArgs.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookArgs.java
index 6c4b2fd..12e42ec 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookArgs.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookArgs.java
@@ -25,12 +25,17 @@
import com.google.gerrit.server.IdentifiedUser;
import com.google.gerrit.server.config.SitePaths;
import com.google.gerrit.server.git.GitRepositoryManager;
+import com.google.inject.Inject;
import com.google.inject.Provider;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
class HookArgs {
+ interface Factory {
+ HookArgs create();
+ }
+
final IdentifiedUser.GenericFactory identifiedUserFactory;
final Provider<String> urlProvider;
final HookMetrics metrics;
@@ -39,6 +44,7 @@
private final List<String> args;
+ @Inject
HookArgs(
IdentifiedUser.GenericFactory identifiedUserFactory,
Provider<String> urlProvider,
@@ -82,6 +88,8 @@
if (account != null) {
args.add(name);
args.add(format(account));
+
+ add(name + "-username", account.username);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookFactory.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookFactory.java
index 2969358..c3ca6e1 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookFactory.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookFactory.java
@@ -16,14 +16,9 @@
import static com.google.common.base.MoreObjects.firstNonNull;
-import com.google.gerrit.common.Nullable;
-import com.google.gerrit.server.IdentifiedUser;
-import com.google.gerrit.server.config.CanonicalWebUrl;
import com.google.gerrit.server.config.GerritServerConfig;
import com.google.gerrit.server.config.SitePaths;
-import com.google.gerrit.server.git.GitRepositoryManager;
import com.google.inject.Inject;
-import com.google.inject.Provider;
import com.google.inject.Singleton;
import java.nio.file.Path;
import java.nio.file.Paths;
@@ -34,31 +29,20 @@
private final HookQueue queue;
private final HookExecutor syncHookExecutor;
private final Config config;
- private final IdentifiedUser.GenericFactory identifiedUserFactory;
- private final HookMetrics metrics;
- private final Provider<String> urlProvider;
private final Path hooksPath;
- private final GitRepositoryManager gitManager;
- private final SitePaths sitePaths;
+ private final HookArgs.Factory argsFactory;
@Inject
HookFactory(
HookQueue queue,
HookExecutor syncHookExecutor,
@GerritServerConfig Config config,
- IdentifiedUser.GenericFactory identifiedUserFactory,
- @CanonicalWebUrl @Nullable Provider<String> urlProvider,
- HookMetrics metrics,
SitePaths sitePaths,
- GitRepositoryManager gitManager) {
+ HookArgs.Factory argsFactory) {
this.queue = queue;
this.syncHookExecutor = syncHookExecutor;
this.config = config;
- this.identifiedUserFactory = identifiedUserFactory;
- this.metrics = metrics;
- this.urlProvider = urlProvider;
- this.gitManager = gitManager;
- this.sitePaths = sitePaths;
+ this.argsFactory = argsFactory;
String v = config.getString("hooks", null, "path");
if (v != null) {
@@ -73,15 +57,15 @@
return hooksPath.resolve(firstNonNull(v, defaultName));
}
- public AsynchronousHook createAsync(String configName, String defaultName) {
+ public Hook createAsync(String configName, String defaultName) {
return new AsynchronousHook(queue, getHookPath(configName, defaultName));
}
- public SynchronousHook createSync(String configName, String defaultName) {
+ public Hook createSync(String configName, String defaultName) {
return new SynchronousHook(syncHookExecutor, getHookPath(configName, defaultName));
}
public HookArgs createArgs() {
- return new HookArgs(identifiedUserFactory, urlProvider, metrics, gitManager, sitePaths);
+ return argsFactory.create();
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookQueue.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookQueue.java
index 6a5e33e..bc7e5eb 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookQueue.java
@@ -19,11 +19,12 @@
import com.google.inject.Inject;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.concurrent.ScheduledExecutorService;
class HookQueue implements LifecycleListener {
private final WorkQueue workQueue;
- private WorkQueue.Executor queue;
+ private ScheduledExecutorService queue;
@Inject
HookQueue(WorkQueue queue) {
@@ -48,7 +49,6 @@
@Override
public void stop() {
if (queue != null) {
- queue.unregisterWorkQueue();
queue.shutdownNow();
queue = null;
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/Module.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/Module.java
index 2dcce56..df16d15 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/Module.java
@@ -14,12 +14,12 @@
package com.googlesource.gerrit.plugins.hooks;
+import com.google.gerrit.extensions.config.FactoryModule;
import com.google.gerrit.extensions.events.AgreementSignupListener;
import com.google.gerrit.extensions.events.ChangeAbandonedListener;
import com.google.gerrit.extensions.events.ChangeMergedListener;
import com.google.gerrit.extensions.events.ChangeRestoredListener;
import com.google.gerrit.extensions.events.CommentAddedListener;
-import com.google.gerrit.extensions.events.DraftPublishedListener;
import com.google.gerrit.extensions.events.GitReferenceUpdatedListener;
import com.google.gerrit.extensions.events.HashtagsEditedListener;
import com.google.gerrit.extensions.events.LifecycleListener;
@@ -31,11 +31,10 @@
import com.google.gerrit.extensions.registration.DynamicSet;
import com.google.gerrit.server.git.validators.CommitValidationListener;
import com.google.gerrit.server.git.validators.RefOperationValidationListener;
-import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
import com.google.inject.internal.UniqueAnnotations;
-class Module extends AbstractModule {
+class Module extends FactoryModule {
@Override
protected void configure() {
bind(HookQueue.class).in(Scopes.SINGLETON);
@@ -43,12 +42,13 @@
bind(HookExecutor.class).in(Scopes.SINGLETON);
bind(LifecycleListener.class).annotatedWith(UniqueAnnotations.create()).to(HookExecutor.class);
+ factory(HookArgs.Factory.class);
+
DynamicSet.bind(binder(), AgreementSignupListener.class).to(AgreementSignup.class);
DynamicSet.bind(binder(), ChangeAbandonedListener.class).to(ChangeAbandoned.class);
DynamicSet.bind(binder(), ChangeMergedListener.class).to(ChangeMerged.class);
DynamicSet.bind(binder(), ChangeRestoredListener.class).to(ChangeRestored.class);
DynamicSet.bind(binder(), CommentAddedListener.class).to(CommentAdded.class);
- DynamicSet.bind(binder(), DraftPublishedListener.class).to(DraftPublished.class);
DynamicSet.bind(binder(), GitReferenceUpdatedListener.class).to(GitReferenceUpdated.class);
DynamicSet.bind(binder(), HashtagsEditedListener.class).to(HashtagsEdited.class);
DynamicSet.bind(binder(), NewProjectCreatedListener.class).to(NewProjectCreated.class);
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/NewProjectCreated.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/NewProjectCreated.java
index 5ff73f7..0cf0e88 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/NewProjectCreated.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/NewProjectCreated.java
@@ -20,7 +20,7 @@
@Singleton
class NewProjectCreated implements NewProjectCreatedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -34,6 +34,6 @@
HookArgs args = hookFactory.createArgs();
args.add("--project", event.getProjectName());
args.add("--head", event.getHeadName());
- hook.submit(event.getProjectName(), args);
+ hook.execute(event.getProjectName(), args);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java
index d9b38e4..5840874 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java
@@ -26,7 +26,7 @@
import org.eclipse.jgit.lib.ObjectId;
public class RefUpdate implements RefOperationValidationListener {
- private final SynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -47,11 +47,12 @@
HookArgs args = hookFactory.createArgs();
args.add("--project", projectName);
args.add("--uploader", refEvent.user.getNameEmail());
+ args.add("--uploader-username", refEvent.user.getUserName());
args.add("--oldrev", getObjectId(refEvent.command.getOldId()).getName());
args.add("--newrev", getObjectId(refEvent.command.getNewId()).getName());
args.add("--refname", refEvent.command.getRefName());
- HookResult result = hook.run(projectName, args);
+ HookResult result = hook.execute(projectName, args);
if (result != null) {
String output = result.toString();
if (result.getExitValue() != 0) {
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/ReviewerAdded.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/ReviewerAdded.java
index fca527d..9929255 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/ReviewerAdded.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/ReviewerAdded.java
@@ -22,7 +22,7 @@
@Singleton
class ReviewerAdded implements ReviewerAddedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -44,7 +44,7 @@
args.add("--branch", c.branch);
args.add("--reviewer", reviewer);
- hook.submit(c.project, args);
+ hook.execute(c.project, args);
}
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/ReviewerDeleted.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/ReviewerDeleted.java
index e23677d..0cf6ce7 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/ReviewerDeleted.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/ReviewerDeleted.java
@@ -21,7 +21,7 @@
@Singleton
class ReviewerDeleted implements ReviewerDeletedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -43,6 +43,6 @@
args.add("--reviewer", event.getReviewer());
args.addApprovals(event.getNewApprovals(), event.getOldApprovals());
- hook.submit(c.project, args);
+ hook.execute(c.project, args);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/RevisionCreated.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/RevisionCreated.java
index cd4a9d1..8ccc226 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/RevisionCreated.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/RevisionCreated.java
@@ -21,7 +21,7 @@
@Singleton
public class RevisionCreated implements RevisionCreatedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -36,7 +36,6 @@
ChangeInfo c = event.getChange();
args.add("--change", c.id);
- args.add("--is-draft", event.getRevision().draft);
args.add("--kind", String.valueOf(event.getRevision().kind));
args.addUrl(c);
args.add("--change-owner", c.owner);
@@ -47,6 +46,6 @@
args.add("--commit", event.getRevision().commit.commit);
args.add("--patchset", event.getRevision()._number);
- hook.submit(c.project, args);
+ hook.execute(c.project, args);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/SynchronousHook.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/SynchronousHook.java
index 03cbc40..d4dfaf8 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/SynchronousHook.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/SynchronousHook.java
@@ -24,11 +24,13 @@
this.executor = executor;
}
- HookResult run(HookArgs args) {
+ @Override
+ HookResult execute(HookArgs args) {
return executor.submit(path, args);
}
- HookResult run(String projectName, HookArgs args) {
+ @Override
+ HookResult execute(String projectName, HookArgs args) {
return executor.submit(projectName, path, args);
}
}
diff --git a/src/main/java/com/googlesource/gerrit/plugins/hooks/TopicEdited.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/TopicEdited.java
index e608694..62407dd 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/TopicEdited.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/TopicEdited.java
@@ -21,7 +21,7 @@
@Singleton
class TopicEdited implements TopicEditedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -43,6 +43,6 @@
args.add("--old-topic", event.getOldTopic());
args.add("--new-topic", event.getChange().topic);
- hook.submit(c.project, args);
+ hook.execute(c.project, args);
}
}
diff --git a/src/main/resources/Documentation/hooks.md b/src/main/resources/Documentation/hooks.md
index 1fcb0c9..09a7c25 100644
--- a/src/main/resources/Documentation/hooks.md
+++ b/src/main/resources/Documentation/hooks.md
@@ -15,7 +15,7 @@
up server threads. See [`hooks.syncHookTimeout`][1] for configuration details.
```
- ref-update --project <project name> --refname <refname> --uploader <uploader> --oldrev <sha1> --newrev <sha1>
+ ref-update --project <project name> --refname <refname> --uploader <uploader> --uploader-username <username> --oldrev <sha1> --newrev <sha1>
```
commit-received
@@ -31,37 +31,28 @@
up server threads. See [`hooks.syncHookTimeout`][1] for configuration details.
```
- commit-received --project <project name> --refname <refname> --uploader <uploader> --oldrev <sha1> --newrev <sha1> --cmdref <refname>
+ commit-received --project <project name> --refname <refname> --uploader <uploader> --uploader-username <username> --oldrev <sha1> --newrev <sha1> --cmdref <refname>
```
patchset-created
----------------
-Called whenever a patchset is created (this includes new changes and drafts).
+Called whenever a patchset is created (this includes new changes).
```
- patchset-created --change <change id> --is-draft <boolean> --kind <change kind> --change-url <change url> --change-owner <change owner> --project <project name> --branch <branch> --topic <topic> --uploader <uploader> --commit <sha1> --patchset <patchset id>
+ patchset-created --change <change id> --kind <change kind> --change-url <change url> --change-owner <change owner> --change-owner-username <username> --project <project name> --branch <branch> --topic <topic> --uploader <uploader> --uploader-username <username> --commit <sha1> --patchset <patchset id>
```
The `--kind` parameter represents the kind of change uploaded. See documentation
of [`patchSet`][2] for details.
-draft-published
----------------
-
-Called whenever a draft change is published.
-
-```
- draft-published --change <change id> --change-url <change url> --change-owner <change owner> --project <project name> --branch <branch> --topic <topic> --uploader <uploader> --commit <sha1> --patchset <patchset id>
-```
-
comment-added
-------------
Called whenever a comment is added to a change.
```
- comment-added --change <change id> --is-draft <boolean> --change-url <change url> --change-owner <change owner> --project <project name> --branch <branch> --topic <topic> --author <comment author> --commit <commit> --comment <comment> [--<approval category id> <score> --<approval category id> <score> --<approval category id>-oldValue <score> ...]
+ comment-added --change <change id> --change-url <change url> --change-owner <change owner> --change-owner-username <username> --project <project name> --branch <branch> --topic <topic> --author <comment author> --author-username <username> --commit <commit> --comment <comment> [--<approval category id> <score> --<approval category id> <score> --<approval category id>-oldValue <score> ...]
```
change-merged
@@ -70,7 +61,7 @@
Called whenever a change has been merged.
```
- change-merged --change <change id> --change-url <change url> --change-owner <change owner> --project <project name> --branch <branch> --topic <topic> --submitter <submitter> --commit <sha1> --newrev <sha1>
+ change-merged --change <change id> --change-url <change url> --change-owner <change owner> --change-owner-username <username> --project <project name> --branch <branch> --topic <topic> --submitter <submitter> --submitter-username <username> --commit <sha1> --newrev <sha1>
```
change-abandoned
@@ -79,7 +70,7 @@
Called whenever a change has been abandoned.
```
- change-abandoned --change <change id> --change-url <change url> --change-owner <change owner> --project <project name> --branch <branch> --topic <topic> --abandoner <abandoner> --commit <sha1> --reason <reason>
+ change-abandoned --change <change id> --change-url <change url> --change-owner <change owner> --change-owner-username <username> --project <project name> --branch <branch> --topic <topic> --abandoner <abandoner> --abandoner-username <username> --commit <sha1> --reason <reason>
```
change-restored
@@ -88,7 +79,7 @@
Called whenever a change has been restored.
```
- change-restored --change <change id> --change-url <change url> --change-owner <change owner> --project <project name> --branch <branch> --topic <topic> --restorer <restorer> --commit <sha1> --reason <reason>
+ change-restored --change <change id> --change-url <change url> --change-owner <change owner> --change-owner-username <username> --project <project name> --branch <branch> --topic <topic> --restorer <restorer> --restorer-username <username> --commit <sha1> --reason <reason>
```
ref-updated
@@ -97,7 +88,7 @@
Called whenever a ref has been updated.
```
- ref-updated --oldrev <old rev> --newrev <new rev> --refname <ref name> --project <project name> --submitter <submitter>
+ ref-updated --oldrev <old rev> --newrev <new rev> --refname <ref name> --project <project name> --submitter <submitter> --submitter-username <username>
```
project-created
@@ -115,7 +106,7 @@
Called whenever a reviewer is added to a change.
```
- reviewer-added --change <change id> --change-url <change url> --change-owner <change owner> --project <project name> --branch <branch> --reviewer <reviewer>
+ reviewer-added --change <change id> --change-url <change url> --change-owner <change owner> --change-owner-username <username> --project <project name> --branch <branch> --reviewer <reviewer> --reviewer-username <username>
```
reviewer-deleted
@@ -124,7 +115,7 @@
Called whenever a reviewer (with a vote) is removed from a change.
```
- reviewer-deleted --change <change id> --change-url <change url> --change-owner <change owner> --project <project name> --branch <branch> --reviewer <reviewer> [--<approval category id> <score> --<approval category id> <score> ...]
+ reviewer-deleted --change <change id> --change-url <change url> --change-owner <change owner> --change-owner-username <username> --project <project name> --branch <branch> --reviewer <reviewer> [--<approval category id> <score> --<approval category id> <score> ...]
```
topic-changed
@@ -133,7 +124,7 @@
Called whenever a change's topic is changed from the Web UI or via the REST API.
```
- topic-changed --change <change id> --change-owner <change owner> --project <project name> --branch <branch> --changer <changer> --old-topic <old topic> --new-topic <new topic>
+ topic-changed --change <change id> --change-owner <change owner> --change-owner-username <username> --project <project name> --branch <branch> --changer <changer> --changer-username <username> --old-topic <old topic> --new-topic <new topic>
```
hashtags-changed
@@ -143,7 +134,7 @@
or via the REST API.
```
- hashtags-changed --change <change id> --change-owner <change owner> --project <project name> --branch <branch> --editor <editor> --added <hashtag> --removed <hashtag> --hashtag <hashtag>
+ hashtags-changed --change <change id> --change-owner <change owner> --change-owner-username <username> --project <project name> --branch <branch> --editor <editor> --editor-username <username> --added <hashtag> --removed <hashtag> --hashtag <hashtag>
```
The `--added` parameter may be passed multiple times, once for each