From 51a00ff43384d07014ba6f1d1b39114bc9c88d27 Mon Sep 17 00:00:00 2001 From: akkaradej Date: Thu, 22 Oct 2015 00:14:26 +0700 Subject: [PATCH 1/2] Add test for shallow cloning when source is a ssh protocol --- test/core/resolvers/gitRemoteResolver.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/test/core/resolvers/gitRemoteResolver.js b/test/core/resolvers/gitRemoteResolver.js index 6381424eb..30c7a0bd6 100644 --- a/test/core/resolvers/gitRemoteResolver.js +++ b/test/core/resolvers/gitRemoteResolver.js @@ -356,6 +356,26 @@ describe('GitRemoteResolver', function () { }); }); + it('should evaluate to true when source is a ssh protocol and host is defined to support shallow cloning', function (next) { + var testSource = 'git@foo:bar.git'; + + var MyGitRemoteResolver = gitRemoteResolverFactory( + createCmdHandlerFn(testSource, multiline(function () {/* + foo: bar + Content-Type: application/x-git-upload-pack-advertisement + 1234: 5678 + */})) + ); + + var resolver = new MyGitRemoteResolver({ source: testSource }, defaultConfig({ shallowCloneHosts: ['foo'] }), logger); + + resolver._shallowClone().then(function (shallowCloningSupported) { + expect(shallowCloningSupported).to.be(true); + + next(); + }); + }); + it('should cache hosts that support shallow cloning', function (next) { var testSource = 'https://foo/bar.git'; From dcd06d80a39d94cedc6c84f7b0796c32b19521bb Mon Sep 17 00:00:00 2001 From: akkaradej Date: Thu, 22 Oct 2015 00:15:05 +0700 Subject: [PATCH 2/2] Fix missing host from ssh source --- lib/core/resolvers/GitRemoteResolver.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/core/resolvers/GitRemoteResolver.js b/lib/core/resolvers/GitRemoteResolver.js index 1a8e9be90..b8f32f8be 100644 --- a/lib/core/resolvers/GitRemoteResolver.js +++ b/lib/core/resolvers/GitRemoteResolver.js @@ -19,14 +19,14 @@ function GitRemoteResolver(decEndpoint, config, logger) { this._name = this._name.slice(0, -4); } - // Get the host of this source + // Get the remote of this source if (!/:\/\//.test(this._source)) { - this._host = url.parse('ssh://' + this._source).host; + this._remote = url.parse('ssh://' + this._source); } else { - this._host = url.parse(this._source).host; + this._remote = url.parse(this._source); } - - this._remote = url.parse(this._source); + + this._host = this._remote.host; // Verify whether the server supports shallow cloning this._shallowClone = this._supportsShallowCloning;