diff options
author | Markus Duft <markus.duft@ssi-schaefer.com> | 2018-06-11 17:12:00 +0200 |
---|---|---|
committer | Matthias Sohn <matthias.sohn@sap.com> | 2018-06-12 09:49:15 +0200 |
commit | 01c52a58f66e1582e5c0cea17801fb347f3163c9 (patch) | |
tree | e5d3eba960d4507ae193b4d835c5bdbcdb02dc76 /org.eclipse.jgit.lfs/src | |
parent | 747ad8b166fedca0df217923fda184cfcd661757 (diff) | |
download | jgit-01c52a58f66e1582e5c0cea17801fb347f3163c9.tar.gz jgit-01c52a58f66e1582e5c0cea17801fb347f3163c9.zip |
Fix issues with LFS on GitHub (SSH)
* URIish seems to have a tiny feature (bug?). The path of the URI
starts with a '/' only if the URI has a port set (it seems).
* GitHub does not return SSH authorization on a single line as Gerrit
does - need to account for that.
* Increase the SSH git-lfs-authenticate timeout, as GitHub sometimes
responds slower than expected.
* Guard against NPE in case the download action does not contain any
additional headers.
Change-Id: Icd1ead3d015479fd4b8bbd42ed42129b0abfb95c
Signed-off-by: Markus Duft <markus.duft@ssi-schaefer.com>
Diffstat (limited to 'org.eclipse.jgit.lfs/src')
-rw-r--r-- | org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java | 24 | ||||
-rw-r--r-- | org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java | 1 |
2 files changed, 20 insertions, 5 deletions
diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java index 3ac69923f2..bac980bb8d 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsConnectionFactory.java @@ -68,13 +68,18 @@ import org.eclipse.jgit.transport.URIish; import org.eclipse.jgit.transport.http.HttpConnection; import org.eclipse.jgit.util.HttpSupport; import org.eclipse.jgit.util.SshSupport; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Provides means to get a valid LFS connection for a given repository. */ public class LfsConnectionFactory { - private static final int SSH_AUTH_TIMEOUT_SECONDS = 5; + private static final Logger log = LoggerFactory + .getLogger(LfsConnectionFactory.class); + + private static final int SSH_AUTH_TIMEOUT_SECONDS = 30; private static final String SCHEME_HTTPS = "https"; //$NON-NLS-1$ private static final String SCHEME_SSH = "ssh"; //$NON-NLS-1$ private static final Map<String, AuthCache> sshAuthCache = new TreeMap<>(); @@ -162,7 +167,7 @@ public class LfsConnectionFactory { Map<String, String> additionalHeaders, String remoteUrl) { try { URIish u = new URIish(remoteUrl); - if (SCHEME_SSH.equals(u.getScheme())) { + if (u.getScheme() == null || SCHEME_SSH.equals(u.getScheme())) { Protocol.ExpiringAction action = getSshAuthentication( db, purpose, remoteUrl, u); additionalHeaders.putAll(action.header); @@ -171,6 +176,7 @@ public class LfsConnectionFactory { return remoteUrl + Protocol.INFO_LFS_ENDPOINT; } } catch (Exception e) { + log.error(LfsText.get().cannotDiscoverLfs, e); return null; // could not discover } } @@ -226,8 +232,10 @@ public class LfsConnectionFactory { .create(contentUrl, HttpSupport .proxyFor(ProxySelector.getDefault(), contentUrl)); contentServerConn.setRequestMethod(method); - action.header - .forEach((k, v) -> contentServerConn.setRequestProperty(k, v)); + if (action.header != null) { + action.header.forEach( + (k, v) -> contentServerConn.setRequestProperty(k, v)); + } if (contentUrl.getProtocol().equals(SCHEME_HTTPS) && !repo.getConfig().getBoolean(HttpConfig.HTTP, HttpConfig.SSL_VERIFY_KEY, true)) { @@ -241,7 +249,13 @@ public class LfsConnectionFactory { } private static String extractProjectName(URIish u) { - String path = u.getPath().substring(1); + String path = u.getPath(); + + // begins with a slash if the url contains a port (gerrit vs. github). + if (path.startsWith("/")) { //$NON-NLS-1$ + path = path.substring(1); + } + if (path.endsWith(org.eclipse.jgit.lib.Constants.DOT_GIT)) { return path.substring(0, path.length() - 4); } else { diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java index d7d0fe186a..d51203a740 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/internal/LfsText.java @@ -60,6 +60,7 @@ public class LfsText extends TranslationBundle { } // @formatter:off + /***/ public String cannotDiscoverLfs; /***/ public String corruptLongObject; /***/ public String inconsistentMediafileLength; /***/ public String inconsistentContentLength; |