Merge branch 'stable-2.15'

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

Change-Id: Iff9772332fd588114f97ba9a213197cb64e0e4dc
This commit is contained in:
David Pursehouse
2018-01-11 21:54:44 +09:00
2 changed files with 22 additions and 8 deletions

View File

@@ -370,6 +370,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;
@@ -377,14 +393,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

@@ -240,6 +240,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())