Merge branch 'stable-2.15'
* stable-2.15: ChangeIT: Temporarily disable tests related to group matching Align SSH create-project with REST API SubmoduleOp: Fix formatting of submodule update commit message Fix Postgresql JDBC driver leaking memory Document that the build works with Python 2 or 3 merge_jars.py: Fix for python 3 compatibility project.py: decode byte output from check_result license and doc: Add support for python3 Bazel: Make build tool chain python 3 compatible ExternalIds NoteDb migration: Avoid intermediate migration state Make PrivateStateChanged and WorkInProgressStateChanged singletons BatchProgramModule: Bind GitReferenceUpdated.DISABLED BatchProgramModule: Don't bind event classes to null Document that Python 2 is required by the build Make event firing classes singleton Fix ConcurrentModificationException when posting reviews Revert partially "Trim multi-line arguments for task name and ssh_log" BaseCommand: Fix formatting of task description with arguments Add analytics to the list of plugins config-plugins: Consistently use "/+doc/" for documentation links config-plugins: Fix link to ref-protection plugin documentation config-plugins: Add readonly plugin to plugin list Add documentation for SshCreateCommandInterceptor Allow plugins to intercept ssh command creation GWT/Poly: Default to "Create initial commit" during project creation Revert "Reduce chance of deadlock in account cache" commit-msg: Adapt to awk behavior change on Cygwin/MSYS Expand docs on how to include external dependencies in core plugins Document how to bundle custom plugins in release.war Group members can't be added as reviewers if a matched username exists Set version to 2.13.11 StreamEventsApiListener: Prevent NPE when account is null Set version to 2.11.11 Replace links to code.google.com/p/gerrit Update issue tracker URL in documentation Update issue tracker URL in POM files Bump jsch to 0.54 Update jsch to 0.1.53 Bump Jsch to 1.52 Change-Id: Icec3dcfe53146da7d66d4d690afdd9e77ee10380
This commit is contained in:
@@ -1161,6 +1161,14 @@ public abstract class AbstractDaemonTest {
|
||||
return createGroup(name, "Administrators");
|
||||
}
|
||||
|
||||
protected String createGroupWithRealName(String name) throws Exception {
|
||||
GroupInput in = new GroupInput();
|
||||
in.name = name;
|
||||
in.ownerId = "Administrators";
|
||||
gApi.groups().create(in);
|
||||
return name;
|
||||
}
|
||||
|
||||
protected String createGroup(String name, String owner) throws Exception {
|
||||
name = name(name);
|
||||
GroupInput in = new GroupInput();
|
||||
|
||||
@@ -29,7 +29,6 @@ import com.google.gerrit.pgm.util.ThreadLimiter;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.change.ChangeResource;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.index.DummyIndexModule;
|
||||
import com.google.gerrit.server.index.change.ChangeSchemaDefinitions;
|
||||
import com.google.gerrit.server.notedb.rebuild.NoteDbMigrator;
|
||||
@@ -189,7 +188,6 @@ public class MigrateToNoteDb extends SiteProgram {
|
||||
@Override
|
||||
public void configure() {
|
||||
install(dbInjector.getInstance(BatchProgramModule.class));
|
||||
bind(GitReferenceUpdated.class).toInstance(GitReferenceUpdated.DISABLED);
|
||||
install(new DummyIndexModule());
|
||||
factory(ChangeResource.Factory.class);
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import com.google.gerrit.pgm.util.SiteProgram;
|
||||
import com.google.gerrit.pgm.util.ThreadLimiter;
|
||||
import com.google.gerrit.server.change.ChangeResource;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.index.IndexModule;
|
||||
import com.google.gerrit.server.index.IndexModule.IndexType;
|
||||
import com.google.gerrit.server.index.change.ChangeSchemaDefinitions;
|
||||
@@ -166,7 +165,6 @@ public class Reindex extends SiteProgram {
|
||||
@Override
|
||||
protected void configure() {
|
||||
factory(ChangeResource.Factory.class);
|
||||
bind(GitReferenceUpdated.class).toInstance(GitReferenceUpdated.DISABLED);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -51,6 +51,9 @@ import com.google.gerrit.server.config.DisableReverseDnsLookupProvider;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.config.GitReceivePackGroups;
|
||||
import com.google.gerrit.server.config.GitUploadPackGroups;
|
||||
import com.google.gerrit.server.extensions.events.EventUtil;
|
||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||
import com.google.gerrit.server.extensions.events.RevisionCreated;
|
||||
import com.google.gerrit.server.git.MergeUtil;
|
||||
import com.google.gerrit.server.git.SearchingChangeCacheImpl;
|
||||
import com.google.gerrit.server.git.TagCache;
|
||||
@@ -169,6 +172,9 @@ public class BatchProgramModule extends FactoryModule {
|
||||
factory(SubmitRuleEvaluator.Factory.class);
|
||||
|
||||
bind(ChangeJson.Factory.class).toProvider(Providers.<ChangeJson.Factory>of(null));
|
||||
bind(EventUtil.class).toProvider(Providers.<EventUtil>of(null));
|
||||
bind(GitReferenceUpdated.class).toInstance(GitReferenceUpdated.DISABLED);
|
||||
bind(RevisionCreated.class).toInstance(RevisionCreated.DISABLED);
|
||||
bind(AccountVisibility.class).toProvider(AccountVisibilityProvider.class).in(SINGLETON);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,12 +14,18 @@
|
||||
|
||||
package com.google.gerrit.server.args4j;
|
||||
|
||||
import com.google.gerrit.common.data.GroupDescription;
|
||||
import com.google.gerrit.common.data.GroupReference;
|
||||
import com.google.gerrit.reviewdb.client.AccountGroup;
|
||||
import com.google.gerrit.server.account.GroupBackend;
|
||||
import com.google.gerrit.server.account.GroupBackends;
|
||||
import com.google.gerrit.server.account.GroupCache;
|
||||
import com.google.gerrit.server.account.GroupControl;
|
||||
import com.google.gerrit.server.group.InternalGroup;
|
||||
import com.google.gerrit.server.group.InternalGroupDescription;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.assistedinject.Assisted;
|
||||
import java.util.Optional;
|
||||
import org.kohsuke.args4j.CmdLineException;
|
||||
import org.kohsuke.args4j.CmdLineParser;
|
||||
import org.kohsuke.args4j.OptionDef;
|
||||
@@ -29,20 +35,50 @@ import org.kohsuke.args4j.spi.Setter;
|
||||
|
||||
public class AccountGroupUUIDHandler extends OptionHandler<AccountGroup.UUID> {
|
||||
private final GroupBackend groupBackend;
|
||||
private final GroupControl.Factory groupControlFactory;
|
||||
private final GroupCache groupCache;
|
||||
|
||||
@Inject
|
||||
public AccountGroupUUIDHandler(
|
||||
final GroupBackend groupBackend,
|
||||
final GroupControl.Factory groupControlFactory,
|
||||
@Assisted final CmdLineParser parser,
|
||||
@Assisted final OptionDef option,
|
||||
@Assisted final Setter<AccountGroup.UUID> setter) {
|
||||
@Assisted final Setter<AccountGroup.UUID> setter,
|
||||
GroupCache groupCache) {
|
||||
super(parser, option, setter);
|
||||
this.groupBackend = groupBackend;
|
||||
this.groupControlFactory = groupControlFactory;
|
||||
this.groupCache = groupCache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final int parseArguments(Parameters params) throws CmdLineException {
|
||||
final String n = params.getParameter(0);
|
||||
AccountGroup.UUID uuid = new AccountGroup.UUID(n);
|
||||
if (groupBackend.handles(uuid)) {
|
||||
GroupDescription.Basic d = groupBackend.get(uuid);
|
||||
if (d != null) {
|
||||
setter.addValue(uuid);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Might be a numeric AccountGroup.Id. -> Internal group.
|
||||
if (n.matches("^[1-9][0-9]*$")) {
|
||||
try {
|
||||
AccountGroup.Id groupId = AccountGroup.Id.parse(n);
|
||||
Optional<InternalGroup> groupInternal = groupCache.get(groupId);
|
||||
if (groupInternal.isPresent()) {
|
||||
uuid = new InternalGroupDescription(groupInternal.get()).getGroupUUID();
|
||||
setter.addValue(uuid);
|
||||
return 1;
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
// Ignored
|
||||
}
|
||||
}
|
||||
|
||||
GroupReference group = GroupBackends.findExactSuggestion(groupBackend, n);
|
||||
if (group == null) {
|
||||
throw new CmdLineException(owner, "Group \"" + n + "\" does not exist");
|
||||
|
||||
@@ -19,7 +19,9 @@ import com.google.gerrit.extensions.events.AgreementSignupListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class AgreementSignup {
|
||||
private final DynamicSet<AgreementSignupListener> listeners;
|
||||
private final EventUtil util;
|
||||
|
||||
@@ -23,10 +23,12 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class AssigneeChanged {
|
||||
private static final Logger log = LoggerFactory.getLogger(AssigneeChanged.class);
|
||||
|
||||
|
||||
@@ -29,11 +29,13 @@ import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class ChangeAbandoned {
|
||||
private static final Logger log = LoggerFactory.getLogger(ChangeAbandoned.class);
|
||||
|
||||
|
||||
@@ -29,11 +29,13 @@ import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class ChangeMerged {
|
||||
private static final Logger log = LoggerFactory.getLogger(ChangeMerged.class);
|
||||
|
||||
|
||||
@@ -29,11 +29,13 @@ import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class ChangeRestored {
|
||||
private static final Logger log = LoggerFactory.getLogger(ChangeRestored.class);
|
||||
|
||||
|
||||
@@ -21,10 +21,12 @@ import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class ChangeReverted {
|
||||
private static final Logger log = LoggerFactory.getLogger(ChangeReverted.class);
|
||||
|
||||
|
||||
@@ -30,12 +30,14 @@ import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class CommentAdded {
|
||||
private static final Logger log = LoggerFactory.getLogger(CommentAdded.class);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ import com.google.gerrit.server.query.change.ChangeData;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provider;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.EnumSet;
|
||||
@@ -43,6 +44,7 @@ import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class EventUtil {
|
||||
private static final Logger log = LoggerFactory.getLogger(EventUtil.class);
|
||||
|
||||
@@ -65,7 +67,7 @@ public class EventUtil {
|
||||
|
||||
private final ChangeData.Factory changeDataFactory;
|
||||
private final Provider<ReviewDb> db;
|
||||
private final ChangeJson changeJson;
|
||||
private final ChangeJson.Factory changeJsonFactory;
|
||||
|
||||
@Inject
|
||||
EventUtil(
|
||||
@@ -74,11 +76,11 @@ public class EventUtil {
|
||||
Provider<ReviewDb> db) {
|
||||
this.changeDataFactory = changeDataFactory;
|
||||
this.db = db;
|
||||
this.changeJson = changeJsonFactory.create(CHANGE_OPTIONS);
|
||||
this.changeJsonFactory = changeJsonFactory;
|
||||
}
|
||||
|
||||
public ChangeInfo changeInfo(Change change) throws OrmException {
|
||||
return changeJson.format(change);
|
||||
return changeJsonFactory.create(CHANGE_OPTIONS).format(change);
|
||||
}
|
||||
|
||||
public RevisionInfo revisionInfo(Project project, PatchSet ps)
|
||||
@@ -91,7 +93,7 @@ public class EventUtil {
|
||||
throws OrmException, PatchListNotAvailableException, GpgException, IOException,
|
||||
PermissionBackendException {
|
||||
ChangeData cd = changeDataFactory.create(db.get(), project, ps.getId().getParentKey());
|
||||
return changeJson.getRevisionInfo(cd, ps);
|
||||
return changeJsonFactory.create(CHANGE_OPTIONS).getRevisionInfo(cd, ps);
|
||||
}
|
||||
|
||||
public AccountInfo accountInfo(AccountState accountState) {
|
||||
|
||||
@@ -21,11 +21,13 @@ import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.gerrit.reviewdb.client.Project;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import org.eclipse.jgit.lib.BatchRefUpdate;
|
||||
import org.eclipse.jgit.lib.ObjectId;
|
||||
import org.eclipse.jgit.lib.RefUpdate;
|
||||
import org.eclipse.jgit.transport.ReceiveCommand;
|
||||
|
||||
@Singleton
|
||||
public class GitReferenceUpdated {
|
||||
public static final GitReferenceUpdated DISABLED =
|
||||
new GitReferenceUpdated() {
|
||||
|
||||
@@ -24,12 +24,14 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Collection;
|
||||
import java.util.Set;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class HashtagsEdited {
|
||||
private static final Logger log = LoggerFactory.getLogger(HashtagsEdited.class);
|
||||
|
||||
|
||||
@@ -17,7 +17,9 @@ package com.google.gerrit.server.extensions.events;
|
||||
import com.google.gerrit.extensions.events.PluginEventListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicSet;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
|
||||
@Singleton
|
||||
public class PluginEvent {
|
||||
private final DynamicSet<PluginEventListener> listeners;
|
||||
|
||||
|
||||
@@ -23,10 +23,12 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class PrivateStateChanged {
|
||||
private static final Logger log = LoggerFactory.getLogger(PrivateStateChanged.class);
|
||||
|
||||
|
||||
@@ -30,12 +30,14 @@ import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class ReviewerAdded {
|
||||
private static final Logger log = LoggerFactory.getLogger(ReviewerAdded.class);
|
||||
|
||||
|
||||
@@ -30,12 +30,14 @@ import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class ReviewerDeleted {
|
||||
private static final Logger log = LoggerFactory.getLogger(ReviewerDeleted.class);
|
||||
|
||||
|
||||
@@ -29,14 +29,27 @@ import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class RevisionCreated {
|
||||
private static final Logger log = LoggerFactory.getLogger(RevisionCreated.class);
|
||||
|
||||
public static final RevisionCreated DISABLED =
|
||||
new RevisionCreated() {
|
||||
@Override
|
||||
public void fire(
|
||||
Change change,
|
||||
PatchSet patchSet,
|
||||
AccountState uploader,
|
||||
Timestamp when,
|
||||
NotifyHandling notify) {}
|
||||
};
|
||||
|
||||
private final DynamicSet<RevisionCreatedListener> listeners;
|
||||
private final EventUtil util;
|
||||
|
||||
@@ -46,6 +59,11 @@ public class RevisionCreated {
|
||||
this.util = util;
|
||||
}
|
||||
|
||||
private RevisionCreated() {
|
||||
this.listeners = null;
|
||||
this.util = null;
|
||||
}
|
||||
|
||||
public void fire(
|
||||
Change change,
|
||||
PatchSet patchSet,
|
||||
|
||||
@@ -23,10 +23,12 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class TopicEdited {
|
||||
private static final Logger log = LoggerFactory.getLogger(TopicEdited.class);
|
||||
|
||||
|
||||
@@ -30,12 +30,14 @@ import com.google.gerrit.server.patch.PatchListObjectTooLargeException;
|
||||
import com.google.gerrit.server.permissions.PermissionBackendException;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.Map;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class VoteDeleted {
|
||||
private static final Logger log = LoggerFactory.getLogger(VoteDeleted.class);
|
||||
|
||||
|
||||
@@ -23,10 +23,12 @@ import com.google.gerrit.reviewdb.client.Change;
|
||||
import com.google.gerrit.server.account.AccountState;
|
||||
import com.google.gwtorm.server.OrmException;
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Singleton;
|
||||
import java.sql.Timestamp;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@Singleton
|
||||
public class WorkInProgressStateChanged {
|
||||
private static final Logger log = LoggerFactory.getLogger(WorkInProgressStateChanged.class);
|
||||
|
||||
|
||||
@@ -415,8 +415,13 @@ public class SubmoduleOp {
|
||||
PersonIdent author = null;
|
||||
DirCache dc = readTree(or.rw, currentCommit);
|
||||
DirCacheEditor ed = dc.editor();
|
||||
int count = 0;
|
||||
for (SubmoduleSubscription s : targets.get(subscriber)) {
|
||||
if (count > 0) {
|
||||
msgbuf.append("\n\n");
|
||||
}
|
||||
RevCommit newCommit = updateSubmodule(dc, ed, msgbuf, s);
|
||||
count++;
|
||||
if (newCommit != null) {
|
||||
if (author == null) {
|
||||
author = newCommit.getAuthorIdent();
|
||||
|
||||
@@ -395,12 +395,11 @@ public abstract class BaseCommand implements Command {
|
||||
}
|
||||
|
||||
protected String getTaskDescription() {
|
||||
StringBuilder m = new StringBuilder(commandName);
|
||||
String[] ta = getTrimmedArguments();
|
||||
if (ta != null) {
|
||||
m.append(Joiner.on(" ").join(ta));
|
||||
return commandName + " " + Joiner.on(" ").join(ta);
|
||||
}
|
||||
return m.toString();
|
||||
return commandName;
|
||||
}
|
||||
|
||||
private String getTaskName() {
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.google.gerrit.sshd;
|
||||
import com.google.common.util.concurrent.Atomics;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.google.gerrit.extensions.events.LifecycleListener;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.reviewdb.server.ReviewDb;
|
||||
import com.google.gerrit.server.config.GerritServerConfig;
|
||||
import com.google.gerrit.server.git.WorkQueue;
|
||||
@@ -57,6 +58,7 @@ class CommandFactoryProvider implements Provider<CommandFactory>, LifecycleListe
|
||||
private final ScheduledExecutorService startExecutor;
|
||||
private final ExecutorService destroyExecutor;
|
||||
private final SchemaFactory<ReviewDb> schemaFactory;
|
||||
private final DynamicItem<SshCreateCommandInterceptor> createCommandInterceptor;
|
||||
|
||||
@Inject
|
||||
CommandFactoryProvider(
|
||||
@@ -65,11 +67,13 @@ class CommandFactoryProvider implements Provider<CommandFactory>, LifecycleListe
|
||||
WorkQueue workQueue,
|
||||
SshLog l,
|
||||
SshScope s,
|
||||
SchemaFactory<ReviewDb> sf) {
|
||||
SchemaFactory<ReviewDb> sf,
|
||||
DynamicItem<SshCreateCommandInterceptor> i) {
|
||||
dispatcher = d;
|
||||
log = l;
|
||||
sshScope = s;
|
||||
schemaFactory = sf;
|
||||
createCommandInterceptor = i;
|
||||
|
||||
int threads = cfg.getInt("sshd", "commandStartThreads", 2);
|
||||
startExecutor = workQueue.createQueue(threads, "SshCommandStart");
|
||||
@@ -94,7 +98,12 @@ class CommandFactoryProvider implements Provider<CommandFactory>, LifecycleListe
|
||||
return new CommandFactory() {
|
||||
@Override
|
||||
public Command createCommand(String requestCommand) {
|
||||
return new Trampoline(requestCommand);
|
||||
String c = requestCommand;
|
||||
SshCreateCommandInterceptor interceptor = createCommandInterceptor.get();
|
||||
if (interceptor != null) {
|
||||
c = interceptor.intercept(c);
|
||||
}
|
||||
return new Trampoline(c);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
26
java/com/google/gerrit/sshd/SshCreateCommandInterceptor.java
Normal file
26
java/com/google/gerrit/sshd/SshCreateCommandInterceptor.java
Normal file
@@ -0,0 +1,26 @@
|
||||
// Copyright (C) 2018 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.google.gerrit.sshd;
|
||||
|
||||
public interface SshCreateCommandInterceptor {
|
||||
|
||||
/**
|
||||
* Intrcept SSH command creation
|
||||
*
|
||||
* @param in command name passed in to command instance creation machinery
|
||||
* @return intercepted command name
|
||||
*/
|
||||
String intercept(String in);
|
||||
}
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
package com.google.gerrit.sshd;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.collect.ListMultimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import com.google.gerrit.common.TimeUtil;
|
||||
@@ -283,9 +282,9 @@ class SshLog implements LifecycleListener {
|
||||
return "Command was already destroyed";
|
||||
}
|
||||
StringBuilder commandName = new StringBuilder(dcmd.getCommandName());
|
||||
String[] trimmedArgs = dcmd.getTrimmedArguments();
|
||||
if (trimmedArgs != null) {
|
||||
commandName.append(Joiner.on(".").join(trimmedArgs));
|
||||
String[] args = dcmd.getArguments();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
commandName.append(".").append(args[i]);
|
||||
}
|
||||
return commandName.toString();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import static com.google.inject.Scopes.SINGLETON;
|
||||
|
||||
import com.google.common.base.CharMatcher;
|
||||
import com.google.common.base.Splitter;
|
||||
import com.google.gerrit.extensions.registration.DynamicItem;
|
||||
import com.google.gerrit.extensions.registration.DynamicMap;
|
||||
import com.google.gerrit.lifecycle.LifecycleModule;
|
||||
import com.google.gerrit.server.DynamicOptions;
|
||||
@@ -100,6 +101,7 @@ public class SshModule extends LifecycleModule {
|
||||
.to(SshPluginStarterCallback.class);
|
||||
|
||||
DynamicMap.mapOf(binder(), DynamicOptions.DynamicBean.class);
|
||||
DynamicItem.itemOf(binder(), SshCreateCommandInterceptor.class);
|
||||
|
||||
listener().toInstance(registerInParentInjectors());
|
||||
listener().to(SshLog.class);
|
||||
|
||||
Reference in New Issue
Block a user