Skip to content

Commit

Permalink
fix: ignore noCommittish on tarball url generation
Browse files Browse the repository at this point in the history
Omitting the committish breaks every host's tarball serving
capabilities.

Just override that setting.
  • Loading branch information
isaacs committed Aug 5, 2019
1 parent 1692435 commit 5d4a8d7
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 1 deletion.
3 changes: 2 additions & 1 deletion git-host.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,8 @@ GitHost.prototype.path = function (opts) {
return this._fill(this.pathtemplate, opts)
}

GitHost.prototype.tarball = function (opts) {
GitHost.prototype.tarball = function (opts_) {
var opts = extend({}, opts_, { noCommittish: false })
return this._fill(this.tarballtemplate, opts)
}

Expand Down
1 change: 1 addition & 0 deletions test/bitbucket.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test('fromUrl(bitbucket url)', function (t) {
t.is(hostinfo.file('C'), 'https://bitbucket.org/111/222/raw/' + (branch || 'master') + '/C', label + ' -> file')
t.is(hostinfo.file('C/D'), 'https://bitbucket.org/111/222/raw/' + (branch || 'master') + '/C/D', label + ' -> file')
t.is(hostinfo.tarball(), 'https://bitbucket.org/111/222/get/' + (branch || 'master') + '.tar.gz', label + ' -> tarball')
t.is(hostinfo.tarball({ noCommittish: true }), 'https://bitbucket.org/111/222/get/' + (branch || 'master') + '.tar.gz', label + ' -> tarball')
}

require('./lib/standard-tests')(verify, 'bitbucket.org', 'bitbucket')
Expand Down
1 change: 1 addition & 0 deletions test/gist.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ test('fromUrl(gist url)', function (t) {
t.is(hostinfo.file('C'), 'https://gist.githubusercontent.com/111/' + proj + '/raw/' + (branch ? branch + '/' : '') + 'C', label + ' -> file')
t.is(hostinfo.file('C/D'), 'https://gist.githubusercontent.com/111/' + proj + '/raw/' + (branch ? branch + '/' : '') + 'C/D', label + ' -> file')
t.is(hostinfo.tarball(), 'https://codeload.github.com/gist/' + proj + '/tar.gz/' + (branch || 'master'), label + ' -> tarball')
t.is(hostinfo.tarball({ noCommittish: true }), 'https://codeload.github.com/gist/' + proj + '/tar.gz/' + (branch || 'master'), label + ' -> tarball')
}
}

Expand Down
1 change: 1 addition & 0 deletions test/github.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ test('fromUrl(github url)', function (t) {
t.is(hostinfo.file('C'), 'https://raw.githubusercontent.com/111/222/' + (branch || 'master') + '/C', label + ' -> file')
t.is(hostinfo.file('C/D'), 'https://raw.githubusercontent.com/111/222/' + (branch || 'master') + '/C/D', label + ' -> file')
t.is(hostinfo.tarball(), 'https://codeload.github.com/111/222/tar.gz/' + (branch || 'master'), label + ' -> tarball')
t.is(hostinfo.tarball({ noCommittish: true }), 'https://codeload.github.com/111/222/tar.gz/' + (branch || 'master'), label + ' -> tarball')
}

// github shorturls
Expand Down
1 change: 1 addition & 0 deletions test/gitlab.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test('fromUrl(gitlab url)', function (t) {
t.is(hostinfo.file('C'), 'https://gitlab.com/111/222/raw/' + (branch || 'master') + '/C', label + ' -> file')
t.is(hostinfo.file('C/D'), 'https://gitlab.com/111/222/raw/' + (branch || 'master') + '/C/D', label + ' -> file')
t.is(hostinfo.tarball(), 'https://gitlab.com/111/222/repository/archive.tar.gz?ref=' + (branch || 'master'), label + ' -> tarball')
t.is(hostinfo.tarball({ noCommittish: true }), 'https://gitlab.com/111/222/repository/archive.tar.gz?ref=' + (branch || 'master'), label + ' -> tarball')
}

require('./lib/standard-tests')(verify, 'gitlab.com', 'gitlab')
Expand Down

0 comments on commit 5d4a8d7

Please sign in to comment.