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

Download tar archives from https://github when possible #2263

Merged
merged 1 commit into from Nov 7, 2016
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
14 changes: 3 additions & 11 deletions lib/core/resolvers/GitHubResolver.js
Expand Up @@ -29,9 +29,6 @@ function GitHubResolver(decEndpoint, config, logger) {
this._source += '.git';
}

// Check if it's public
this._public = mout.string.startsWith(this._source, 'git://');

// Use https:// rather than git:// if on a proxy
if (this._config.proxy || this._config.httpsProxy) {
this._source = this._source.replace('git://', 'https://');
Expand All @@ -49,14 +46,10 @@ mout.object.mixIn(GitHubResolver, GitRemoteResolver);
// -----------------

GitHubResolver.prototype._checkout = function () {
// Only fully works with public repositories and tags
// Could work with https/ssh protocol but not with 100% certainty
if (!this._public || !this._resolution.tag) {
return GitRemoteResolver.prototype._checkout.call(this);
}

var msg;
var tarballUrl = 'https://github.com/' + this._org + '/' + this._repo + '/archive/' + this._resolution.tag + '.tar.gz';
var name = this._resolution.tag || this._resolution.branch || this._resolution.commit;
var tarballUrl = 'https://github.com/' + this._org + '/' + this._repo + '/archive/' + name + '.tar.gz';

var file = path.join(this._tempDir, 'archive.tar.gz');
var reqHeaders = {};
var that = this;
Expand Down Expand Up @@ -121,7 +114,6 @@ GitHubResolver.prototype._checkout = function () {

return that._cleanTempDir()
.then(GitRemoteResolver.prototype._checkout.bind(that));

});
};

Expand Down
10 changes: 9 additions & 1 deletion lib/core/resolvers/GitResolver.js
Expand Up @@ -26,10 +26,18 @@ function GitResolver(decEndpoint, config, logger) {
// anyway
mkdirp.sync(config.storage.empty);
process.env.GIT_TEMPLATE_DIR = config.storage.empty;

if (!config.strictSsl) {
process.env.GIT_SSL_NO_VERIFY = 'true';
}
process.env.GIT_TERMINAL_PROMPT = config.interactive ? '1' : '0';

if (!config.interactive) {
process.env.GIT_TERMINAL_PROMPT = '0';

if (!process.env.SSH_ASKPASS) {
process.env.SSH_ASKPASS = 'echo';
}
}

Resolver.call(this, decEndpoint, config, logger);

Expand Down