Merge branch 'stable-2.15'
* stable-2.15: Extract an enum for label functions LabelNormalizer: Remove unused fields and exceptions MoveChange: only keep veto votes SubmitRules: discontinue permission checks LabelNormalizer: stop squashing based on permitted range Trim multi-line arguments for task name and ssh_log PostReview: Remove support for 'strictLabels' option Revert "SSH commands: Set task name for ReviewCommand" Improve naming of group caches Cache groups by member outside of the account cache Remove the dependency of the account cache on the group index Change-Id: I2fb446d4b2137b5f1a78748dec3cfb96a1063c68
This commit is contained in:
@@ -120,9 +120,10 @@ branch.
|
|||||||
Votes that are not permitted for the user are silently ignored.
|
Votes that are not permitted for the user are silently ignored.
|
||||||
|
|
||||||
--label::
|
--label::
|
||||||
Set a label by name to the value 'N'. Invalid votes (invalid label
|
Set a label by name to the value 'N'. The ability to vote on all specified
|
||||||
or invalid value) and votes that are not permitted for the user are
|
labels is required. If the vote is invalid (invalid label or invalid name),
|
||||||
silently ignored.
|
the vote is not permitted for the user, or the vote is on an outdated or
|
||||||
|
closed patch set, return an error instead of silently discarding the vote.
|
||||||
|
|
||||||
--tag::
|
--tag::
|
||||||
-t::
|
-t::
|
||||||
|
@@ -20,11 +20,8 @@ import static java.util.stream.Collectors.joining;
|
|||||||
import static java.util.stream.Collectors.toList;
|
import static java.util.stream.Collectors.toList;
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableList;
|
import com.google.common.collect.ImmutableList;
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
import com.google.gerrit.elasticsearch.ElasticIndexModule;
|
|
||||||
import com.google.gerrit.extensions.config.FactoryModule;
|
import com.google.gerrit.extensions.config.FactoryModule;
|
||||||
import com.google.gerrit.lifecycle.LifecycleManager;
|
import com.google.gerrit.lifecycle.LifecycleManager;
|
||||||
import com.google.gerrit.lucene.LuceneIndexModule;
|
|
||||||
import com.google.gerrit.pgm.util.BatchProgramModule;
|
import com.google.gerrit.pgm.util.BatchProgramModule;
|
||||||
import com.google.gerrit.pgm.util.RuntimeShutdown;
|
import com.google.gerrit.pgm.util.RuntimeShutdown;
|
||||||
import com.google.gerrit.pgm.util.SiteProgram;
|
import com.google.gerrit.pgm.util.SiteProgram;
|
||||||
@@ -33,13 +30,12 @@ import com.google.gerrit.reviewdb.client.Change;
|
|||||||
import com.google.gerrit.reviewdb.client.Project;
|
import com.google.gerrit.reviewdb.client.Project;
|
||||||
import com.google.gerrit.server.change.ChangeResource;
|
import com.google.gerrit.server.change.ChangeResource;
|
||||||
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
import com.google.gerrit.server.extensions.events.GitReferenceUpdated;
|
||||||
import com.google.gerrit.server.index.IndexModule;
|
import com.google.gerrit.server.index.DummyIndexModule;
|
||||||
import com.google.gerrit.server.index.change.ChangeSchemaDefinitions;
|
import com.google.gerrit.server.index.change.ChangeSchemaDefinitions;
|
||||||
import com.google.gerrit.server.notedb.rebuild.NoteDbMigrator;
|
import com.google.gerrit.server.notedb.rebuild.NoteDbMigrator;
|
||||||
import com.google.gerrit.server.schema.DataSourceType;
|
import com.google.gerrit.server.schema.DataSourceType;
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Injector;
|
import com.google.inject.Injector;
|
||||||
import com.google.inject.Module;
|
|
||||||
import com.google.inject.Provider;
|
import com.google.inject.Provider;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -194,25 +190,12 @@ public class MigrateToNoteDb extends SiteProgram {
|
|||||||
public void configure() {
|
public void configure() {
|
||||||
install(dbInjector.getInstance(BatchProgramModule.class));
|
install(dbInjector.getInstance(BatchProgramModule.class));
|
||||||
bind(GitReferenceUpdated.class).toInstance(GitReferenceUpdated.DISABLED);
|
bind(GitReferenceUpdated.class).toInstance(GitReferenceUpdated.DISABLED);
|
||||||
install(getIndexModule());
|
install(new DummyIndexModule());
|
||||||
factory(ChangeResource.Factory.class);
|
factory(ChangeResource.Factory.class);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private Module getIndexModule() {
|
|
||||||
switch (IndexModule.getIndexType(dbInjector)) {
|
|
||||||
case LUCENE:
|
|
||||||
return LuceneIndexModule.singleVersionWithExplicitVersions(
|
|
||||||
ImmutableMap.of(), threads, false);
|
|
||||||
case ELASTICSEARCH:
|
|
||||||
return ElasticIndexModule.singleVersionWithExplicitVersions(
|
|
||||||
ImmutableMap.of(), threads, false);
|
|
||||||
default:
|
|
||||||
throw new IllegalStateException("unsupported index.type");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void stop() {
|
private void stop() {
|
||||||
try {
|
try {
|
||||||
LifecycleManager m = sysManager;
|
LifecycleManager m = sysManager;
|
||||||
|
@@ -16,6 +16,7 @@ package com.google.gerrit.sshd;
|
|||||||
|
|
||||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.util.concurrent.Atomics;
|
import com.google.common.util.concurrent.Atomics;
|
||||||
import com.google.gerrit.common.Nullable;
|
import com.google.gerrit.common.Nullable;
|
||||||
import com.google.gerrit.common.TimeUtil;
|
import com.google.gerrit.common.TimeUtil;
|
||||||
@@ -111,6 +112,9 @@ public abstract class BaseCommand implements Command {
|
|||||||
/** Unparsed command line options. */
|
/** Unparsed command line options. */
|
||||||
private String[] argv;
|
private String[] argv;
|
||||||
|
|
||||||
|
/** trimmed command line arguments. */
|
||||||
|
private String[] trimmedArgv;
|
||||||
|
|
||||||
public BaseCommand() {
|
public BaseCommand() {
|
||||||
task = Atomics.newReference();
|
task = Atomics.newReference();
|
||||||
}
|
}
|
||||||
@@ -156,6 +160,26 @@ public abstract class BaseCommand implements Command {
|
|||||||
this.argv = argv;
|
this.argv = argv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trim the argument if it is spanning multiple lines.
|
||||||
|
*
|
||||||
|
* @return the arguments where all the multiple-line fields are trimmed.
|
||||||
|
*/
|
||||||
|
protected String[] getTrimmedArguments() {
|
||||||
|
if (trimmedArgv == null && argv != null) {
|
||||||
|
trimmedArgv = new String[argv.length];
|
||||||
|
for (int i = 0; i < argv.length; i++) {
|
||||||
|
String arg = argv[i];
|
||||||
|
int indexOfMultiLine = arg.indexOf("\n");
|
||||||
|
if (indexOfMultiLine > -1) {
|
||||||
|
arg = arg.substring(0, indexOfMultiLine).concat(" [trimmed]");
|
||||||
|
}
|
||||||
|
trimmedArgv[i] = arg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return trimmedArgv;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
Future<?> future = task.getAndSet(null);
|
Future<?> future = task.getAndSet(null);
|
||||||
@@ -371,8 +395,11 @@ public abstract class BaseCommand implements Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected String getTaskDescription() {
|
protected String getTaskDescription() {
|
||||||
StringBuilder m = new StringBuilder();
|
StringBuilder m = new StringBuilder(commandName);
|
||||||
m.append(context.getCommandLine());
|
String[] ta = getTrimmedArguments();
|
||||||
|
if (ta != null) {
|
||||||
|
m.append(Joiner.on(" ").join(ta));
|
||||||
|
}
|
||||||
return m.toString();
|
return m.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
|
|
||||||
package com.google.gerrit.sshd;
|
package com.google.gerrit.sshd;
|
||||||
|
|
||||||
|
import com.google.common.base.Joiner;
|
||||||
import com.google.common.collect.ListMultimap;
|
import com.google.common.collect.ListMultimap;
|
||||||
import com.google.common.collect.MultimapBuilder;
|
import com.google.common.collect.MultimapBuilder;
|
||||||
import com.google.gerrit.common.TimeUtil;
|
import com.google.gerrit.common.TimeUtil;
|
||||||
@@ -282,9 +283,9 @@ class SshLog implements LifecycleListener {
|
|||||||
return "Command was already destroyed";
|
return "Command was already destroyed";
|
||||||
}
|
}
|
||||||
StringBuilder commandName = new StringBuilder(dcmd.getCommandName());
|
StringBuilder commandName = new StringBuilder(dcmd.getCommandName());
|
||||||
String[] args = dcmd.getArguments();
|
String[] trimmedArgs = dcmd.getTrimmedArguments();
|
||||||
for (int i = 1; i < args.length; i++) {
|
if (trimmedArgs != null) {
|
||||||
commandName.append(".").append(args[i]);
|
commandName.append(Joiner.on(".").join(trimmedArgs));
|
||||||
}
|
}
|
||||||
return commandName.toString();
|
return commandName.toString();
|
||||||
}
|
}
|
||||||
|
@@ -240,11 +240,6 @@ public class ReviewCommand extends SshCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected String getTaskDescription() {
|
|
||||||
return "gerrit review";
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applyReview(PatchSet patchSet, ReviewInput review) throws RestApiException {
|
private void applyReview(PatchSet patchSet, ReviewInput review) throws RestApiException {
|
||||||
gApi.changes()
|
gApi.changes()
|
||||||
.id(patchSet.getId().getParentKey().get())
|
.id(patchSet.getId().getParentKey().get())
|
||||||
|
Reference in New Issue
Block a user