Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebased version of #1964 #2506

Merged
merged 2 commits into from Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/core/resolvers/GitRemoteResolver.js
Expand Up @@ -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;
Expand Down
20 changes: 20 additions & 0 deletions test/core/resolvers/gitRemoteResolver.js
Expand Up @@ -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';

Expand Down