Merge branch 'stable-2.14' into 'stable-2.15'

* stable-2.14:
  SSH commands: Set task name for ReviewCommand
  [SSH] Extract task name creation to method in BaseCommand

Change-Id: I5caa4289455715e8057ed5cfc343e6dcf46b4538
Signed-off-by: Edwin Kempin <ekempin@google.com>
This commit is contained in:
Edwin Kempin
2018-01-11 13:44:18 +01:00
2 changed files with 22 additions and 8 deletions

View File

@@ -369,6 +369,22 @@ public abstract class BaseCommand implements Command {
}
}
protected String getTaskDescription() {
StringBuilder m = new StringBuilder();
m.append(context.getCommandLine());
return m.toString();
}
private String getTaskName() {
StringBuilder m = new StringBuilder();
m.append(getTaskDescription());
if (user.isIdentifiedUser()) {
IdentifiedUser u = user.asIdentifiedUser();
m.append(" (").append(u.getAccount().getUserName()).append(")");
}
return m.toString();
}
private final class TaskThunk implements CancelableRunnable, ProjectRunnable {
private final CommandRunnable thunk;
private final String taskName;
@@ -376,14 +392,7 @@ public abstract class BaseCommand implements Command {
private TaskThunk(CommandRunnable thunk) {
this.thunk = thunk;
StringBuilder m = new StringBuilder();
m.append(context.getCommandLine());
if (user.isIdentifiedUser()) {
IdentifiedUser u = user.asIdentifiedUser();
m.append(" (").append(u.getAccount().getUserName()).append(")");
}
this.taskName = m.toString();
this.taskName = getTaskName();
}
@Override

View File

@@ -247,6 +247,11 @@ public class ReviewCommand extends SshCommand {
}
}
@Override
protected String getTaskDescription() {
return "gerrit review";
}
private void applyReview(PatchSet patchSet, ReviewInput review) throws RestApiException {
gApi.changes()
.id(patchSet.getId().getParentKey().get())