Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Duft2018-03-08 07:33:17 +0000
committerThomas Wolf2018-04-01 10:22:41 +0000
commit90791a6c117bad0380253eb513c15545e70129dd (patch)
treeffcc948eb471cf123b07ec7024575dfce7d11c24 /org.eclipse.egit.core
parent263705d39d6dcb28911fb7451e4ea57dfd55a1e1 (diff)
downloadegit-90791a6c117bad0380253eb513c15545e70129dd.tar.gz
egit-90791a6c117bad0380253eb513c15545e70129dd.tar.xz
egit-90791a6c117bad0380253eb513c15545e70129dd.zip
Use JGit SshSupport which now contains the runSshCommand method
Code has been moved in the dependent JGit commit. JGit-Dependency: Ifb5adb1342e0fc1f2a70cddf693408d4e0ef7906 Change-Id: Iadacc789a7b2102e115a07b6649c087ea9de0b05 Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
Diffstat (limited to 'org.eclipse.egit.core')
-rw-r--r--org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java49
1 files changed, 4 insertions, 45 deletions
diff --git a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java
index 1035aee2e0..f1e36fba48 100644
--- a/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java
+++ b/org.eclipse.egit.core/src/org/eclipse/egit/core/op/ConfigureGerritAfterCloneTask.java
@@ -9,11 +9,9 @@
*******************************************************************************/
package org.eclipse.egit.core.op;
-import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;
-import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
@@ -31,12 +29,8 @@ import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.lib.StoredConfig;
import org.eclipse.jgit.transport.CredentialsProvider;
import org.eclipse.jgit.transport.RemoteConfig;
-import org.eclipse.jgit.transport.RemoteSession;
-import org.eclipse.jgit.transport.SshSessionFactory;
import org.eclipse.jgit.transport.URIish;
-import org.eclipse.jgit.util.FS;
-import org.eclipse.jgit.util.io.MessageWriter;
-import org.eclipse.jgit.util.io.StreamCopyThread;
+import org.eclipse.jgit.util.SshSupport;
/**
* Configure Gerrit if repository was cloned from a Gerrit server
@@ -219,8 +213,9 @@ public class ConfigureGerritAfterCloneTask implements PostCloneTask {
}
URIish sshUri = u.setPath(""); //$NON-NLS-1$
try {
- String result = runSshCommand(sshUri, credentialsProvider,
- repo.getFS(), GERRIT_SSHD_VERSION_API);
+ String result = SshSupport.runSshCommand(sshUri,
+ credentialsProvider, repo.getFS(),
+ GERRIT_SSHD_VERSION_API, timeout);
return result != null
&& GERRIT_SSHD_REPLY.matcher(result).matches();
} catch (IOException e) {
@@ -266,40 +261,4 @@ public class ConfigureGerritAfterCloneTask implements PostCloneTask {
config.save();
}
- private String runSshCommand(URIish sshUri, CredentialsProvider provider,
- FS fs, String command) throws IOException {
- RemoteSession session = null;
- Process process = null;
- StreamCopyThread errorThread = null;
- try (MessageWriter stderr = new MessageWriter()) {
- session = SshSessionFactory.getInstance().getSession(sshUri,
- provider, fs, 1000 * timeout);
- process = session.exec(command, 0);
- errorThread = new StreamCopyThread(process.getErrorStream(),
- stderr.getRawStream());
- errorThread.start();
- try (BufferedReader reader = new BufferedReader(
- new InputStreamReader(process.getInputStream(),
- Constants.CHARSET))) {
- return reader.readLine();
- }
- } finally {
- if (errorThread != null) {
- try {
- errorThread.halt();
- } catch (InterruptedException e) {
- // Stop waiting and return anyway.
- } finally {
- errorThread = null;
- }
- }
- if (process != null) {
- process.destroy();
- }
- if (session != null) {
- SshSessionFactory.getInstance().releaseSession(session);
- }
- }
- }
-
}

Back to the top