Merge branch 'stable-2.14' into stable-2.15
* stable-2.14:
Implement change-deleted hook
Change-Id: I6a4b39a3332aa773a977a51a9544c2fb99cb772b
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/ChangeDeleted.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeDeleted.java
index 85a4938..ae117f8 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeDeleted.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/ChangeDeleted.java
@@ -21,7 +21,7 @@
@Singleton
public class ChangeDeleted implements ChangeDeletedListener {
- private final AsynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -43,6 +43,6 @@
args.add("--topic", c.topic);
args.add("--deleter", event.getWho());
- 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 e08a043..b03a77b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/CommitReceived.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/CommitReceived.java
@@ -27,7 +27,7 @@
@Singleton
public class CommitReceived implements CommitValidationListener {
- private final SynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -51,11 +51,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..91d3696 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookArgs.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookArgs.java
@@ -18,19 +18,26 @@
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableList;
+import com.google.gerrit.common.Nullable;
import com.google.gerrit.extensions.common.AccountInfo;
import com.google.gerrit.extensions.common.ApprovalInfo;
import com.google.gerrit.extensions.common.ChangeInfo;
import com.google.gerrit.reviewdb.client.Account;
import com.google.gerrit.server.IdentifiedUser;
+import com.google.gerrit.server.config.CanonicalWebUrl;
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,9 +46,10 @@
private final List<String> args;
+ @Inject
HookArgs(
IdentifiedUser.GenericFactory identifiedUserFactory,
- Provider<String> urlProvider,
+ @CanonicalWebUrl @Nullable Provider<String> urlProvider,
HookMetrics metrics,
GitRepositoryManager gitManager,
SitePaths sitePaths) {
@@ -82,6 +90,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 81d1400..f3d8293 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;
@@ -38,31 +33,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) {
@@ -80,15 +64,15 @@
return hookPath;
}
- 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 82b2151..1b2a307 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/HookQueue.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/HookQueue.java
@@ -19,6 +19,7 @@
import com.google.inject.Inject;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.concurrent.ScheduledExecutorService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -27,7 +28,7 @@
private final WorkQueue workQueue;
- private WorkQueue.Executor queue;
+ private ScheduledExecutorService queue;
@Inject
HookQueue(WorkQueue workQueue) {
@@ -54,7 +55,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 8243791..fac480b 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/Module.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/Module.java
@@ -14,13 +14,13 @@
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.ChangeDeletedListener;
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;
@@ -33,11 +33,10 @@
import com.google.gerrit.server.git.validators.CommitValidationListener;
import com.google.gerrit.server.git.validators.MergeValidationListener;
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);
@@ -45,6 +44,8 @@
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(), ChangeDeletedListener.class).to(ChangeDeleted.class);
@@ -52,7 +53,6 @@
DynamicSet.bind(binder(), ChangeRestoredListener.class).to(ChangeRestored.class);
DynamicSet.bind(binder(), CommentAddedListener.class).to(CommentAdded.class);
DynamicSet.bind(binder(), CommitValidationListener.class).to(CommitReceived.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(), MergeValidationListener.class).to(Submit.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 2182614..7eedfa5 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/RefUpdate.java
@@ -28,7 +28,7 @@
@Singleton
public class RefUpdate implements RefOperationValidationListener {
- private final SynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -49,11 +49,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/Submit.java b/src/main/java/com/googlesource/gerrit/plugins/hooks/Submit.java
index 59cfc43..8e2f1e0 100644
--- a/src/main/java/com/googlesource/gerrit/plugins/hooks/Submit.java
+++ b/src/main/java/com/googlesource/gerrit/plugins/hooks/Submit.java
@@ -27,7 +27,7 @@
@Singleton
public class Submit implements MergeValidationListener {
- private final SynchronousHook hook;
+ private final Hook hook;
private final HookFactory hookFactory;
@Inject
@@ -55,7 +55,7 @@
args.add("--patchset", patchSetId.get());
args.add("--commit", commit.getId().name());
- HookResult result = hook.run(projectName, args);
+ HookResult result = hook.execute(projectName, args);
if (result != null && result.getExitValue() != 0) {
throw new MergeValidationException(result.toString());
}
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 c8b6c81..324f842 100644
--- a/src/main/resources/Documentation/hooks.md
+++ b/src/main/resources/Documentation/hooks.md
@@ -19,7 +19,7 @@
from the hook will be returned to the user, regardless of the return code.
```
- 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,7 +31,7 @@
from the hook will be returned to the user, regardless of the return code.
```
- 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>
```
### submit
@@ -52,29 +52,21 @@
### 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
@@ -82,7 +74,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
@@ -90,7 +82,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-deleted
@@ -106,7 +98,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
@@ -114,7 +106,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
@@ -130,7 +122,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
@@ -138,7 +130,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
@@ -146,7 +138,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
@@ -155,7 +147,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