From dca0d1667cf5e6e8b14c0ad633429f2ce8fcc64c Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Thu, 10 Apr 2014 18:58:09 -0400
Subject: [PATCH] Add administrative SSH command to manage Gitblit's runtime settings
---
src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java | 35 ++++++++++++++++-------------------
1 files changed, 16 insertions(+), 19 deletions(-)
diff --git a/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java b/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java
index 4162a40..6a190df 100644
--- a/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java
+++ b/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java
@@ -216,6 +216,11 @@
return "";
}
+ protected void showHelp() throws UnloggedFailure {
+ argv = new String [] { "--help" };
+ parseCommandLine();
+ }
+
private final class TaskThunk implements CancelableRunnable {
private final CommandRunnable thunk;
private final String taskName;
@@ -232,7 +237,7 @@
public void cancel() {
synchronized (this) {
try {
- // onExit(/*STATUS_CANCEL*/);
+ onExit(STATUS_CANCEL);
} finally {
ctx = null;
}
@@ -317,18 +322,12 @@
/**
* Terminate this command and return a result code to the remote client.
* <p>
- * Commands should invoke this at most once. Once invoked, the command may
- * lose access to request based resources as any callbacks previously
- * registered with {@link RequestCleanup} will fire.
+ * Commands should invoke this at most once.
*
- * @param rc
- * exit code for the remote client.
+ * @param rc exit code for the remote client.
*/
protected void onExit(final int rc) {
exit.onExit(rc);
- // if (cleanup != null) {
- // cleanup.run();
- // }
}
private int handleError(final Throwable e) {
@@ -346,16 +345,14 @@
} else {
final StringBuilder m = new StringBuilder();
m.append("Internal server error");
- // if (userProvider.get().isIdentifiedUser()) {
- // final IdentifiedUser u = (IdentifiedUser) userProvider.get();
- // m.append(" (user ");
- // m.append(u.getAccount().getUserName());
- // m.append(" account ");
- // m.append(u.getAccountId());
- // m.append(")");
- // }
- // m.append(" during ");
- // m.append(contextProvider.get().getCommandLine());
+ String user = ctx.getClient().getUsername();
+ if (user != null) {
+ m.append(" (user ");
+ m.append(user);
+ m.append(")");
+ }
+ m.append(" during ");
+ m.append(ctx.getCommandLine());
log.error(m.toString(), e);
}
--
Gitblit v1.9.1