Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ class GitFetcher extends Fetcher {
integrity: null, // it'll always be different, if we have one
}).extract(tmp).then(() => handler(`${tmp}${this.spec.gitSubdir || ''}`), er => {
// fall back to ssh download if tarball fails
if (er.constructor.name.match(/^Http/)) {
if (typeof er.statusCode === 'number' && er.statusCode >= 400) {
return this.#clone(handler, false)
} else {
throw er
Expand Down
17 changes: 17 additions & 0 deletions test/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const rimraf = require('rimraf')
const tar = require('tar')
const spawnNpm = require('../lib/util/npm.js')
const GitFetcher = require('../lib/git.js')
const RemoteFetcher = require('../lib/remote.js')

// set this up first, so we can use 127.0.0.1 as our "hosted git" service
const httpPort = 18000 + (+process.env.TAP_CHILD_ID || 0)
Expand Down Expand Up @@ -631,6 +632,22 @@ t.test('fetch a private repo where the tgz is a 404', { skip: isWindows && 'posi
return gf.extract(me + '/no-tgz')
})

t.test('fetch a private repo where the tgz is a 404 and http error has minified class name',
{ skip: isWindows && 'posix only' }, async t => {
const gf = new GitFetcher(`localhost:repo/x#${REPO_HEAD}`, opts)
const origExtract = RemoteFetcher.prototype.extract
RemoteFetcher.prototype.extract = () => {
const err = new Error('404 Not Found')
err.statusCode = 404
err.code = 'E404'
return Promise.reject(err)
}
t.teardown(() => {
RemoteFetcher.prototype.extract = origExtract
})
await gf.extract(me + '/no-tgz')
})

t.test('fetch a private repo where the tgz is not a tarball', { skip: isWindows && 'posix only' },
t => {
const gf = new GitFetcher(`localhost:repo/x#${REPO_HEAD}`, opts)
Expand Down