Merge "Merge branch 'stable-2.14' into stable-2.15" into stable-2.15
This commit is contained in:
commit
ff03f0b455
@ -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;
|
||||||
@ -110,6 +111,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();
|
||||||
}
|
}
|
||||||
@ -155,6 +159,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);
|
||||||
@ -370,8 +394,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.audit.AuditService;
|
import com.google.gerrit.audit.AuditService;
|
||||||
@ -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();
|
||||||
}
|
}
|
||||||
|
@ -241,11 +241,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())
|
||||||
|
Loading…
x
Reference in New Issue
Block a user