From 0d232164930581ccc9eac1b54e4c624a62f107bd Mon Sep 17 00:00:00 2001 From: James Moger Date: Sun, 16 Mar 2014 16:02:57 -0400 Subject: [PATCH] Pass IGitblit into the SSH command context --- .../com/gitblit/transport/ssh/SshCommandContext.java | 10 +++++++++- .../com/gitblit/transport/ssh/SshCommandFactory.java | 2 +- .../gitblit/transport/ssh/commands/BaseCommand.java | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gitblit/transport/ssh/SshCommandContext.java b/src/main/java/com/gitblit/transport/ssh/SshCommandContext.java index de79dacc..163d0795 100644 --- a/src/main/java/com/gitblit/transport/ssh/SshCommandContext.java +++ b/src/main/java/com/gitblit/transport/ssh/SshCommandContext.java @@ -15,16 +15,24 @@ */ package com.gitblit.transport.ssh; +import com.gitblit.manager.IGitblit; + public class SshCommandContext { + private final IGitblit gitblit; private final SshDaemonClient client; private final String commandLine; - public SshCommandContext(SshDaemonClient client, String commandLine) { + public SshCommandContext(IGitblit gitblit, SshDaemonClient client, String commandLine) { + this.gitblit = gitblit; this.client = client; this.commandLine = commandLine; } + public IGitblit getGitblit() { + return gitblit; + } + public SshDaemonClient getClient() { return client; } diff --git a/src/main/java/com/gitblit/transport/ssh/SshCommandFactory.java b/src/main/java/com/gitblit/transport/ssh/SshCommandFactory.java index 48e8869a..df288db0 100644 --- a/src/main/java/com/gitblit/transport/ssh/SshCommandFactory.java +++ b/src/main/java/com/gitblit/transport/ssh/SshCommandFactory.java @@ -107,7 +107,7 @@ public class SshCommandFactory implements CommandFactory { root.setReceivePackFactory(new GitblitReceivePackFactory(gitblit)); root.setAuthenticator(keyAuthenticator); - root.setContext(new SshCommandContext(client, cmdLine)); + root.setContext(new SshCommandContext(gitblit, client, cmdLine)); return root; } 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 28dfbdd0..fb2d369f 100644 --- a/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java +++ b/src/main/java/com/gitblit/transport/ssh/commands/BaseCommand.java @@ -87,6 +87,7 @@ public abstract class BaseCommand implements Command, SessionAware { @Override public void destroy() { + ctx = null; } protected static PrintWriter toPrintWriter(final OutputStream o) { -- 2.39.5