Skip to content

Commit e69549f

Browse files
committed
fix: remove path escaping since we do not need it when not using a shell
1 parent 766bfbe commit e69549f

File tree

4 files changed

+9
-20
lines changed

4 files changed

+9
-20
lines changed

lib/clone.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const { basename, resolve } = require('path')
2424

2525
const revs = require('./revs.js')
2626
const spawn = require('./spawn.js')
27-
const { isWindows, escapePath } = require('./utils.js')
27+
const { isWindows } = require('./utils.js')
2828

2929
const pickManifest = require('npm-pick-manifest')
3030
const fs = require('fs')
@@ -112,7 +112,7 @@ const branch = (repo, revDoc, target, opts) => {
112112
'-b',
113113
revDoc.ref,
114114
repo,
115-
escapePath(target, opts),
115+
target,
116116
'--recurse-submodules'
117117
]
118118
if (maybeShallow(repo, opts)) { args.push('--depth=1') }
@@ -125,7 +125,7 @@ const plain = (repo, revDoc, target, opts) => {
125125
const args = [
126126
'clone',
127127
repo,
128-
escapePath(target, opts),
128+
target,
129129
'--recurse-submodules'
130130
]
131131
if (maybeShallow(repo, opts)) { args.push('--depth=1') }
@@ -151,7 +151,7 @@ const unresolved = (repo, ref, target, opts) => {
151151
// can't do this one shallowly, because the ref isn't advertised
152152
// but we can avoid checking out the working dir twice, at least
153153
const lp = isWindows(opts) ? ['--config', 'core.longpaths=true'] : []
154-
const cloneArgs = ['clone', '--mirror', '-q', repo, escapePath(target + '/.git', opts)]
154+
const cloneArgs = ['clone', '--mirror', '-q', repo, target + '/.git']
155155
const git = (args) => spawn(args, { ...opts, cwd: target })
156156
return mkdirp(target)
157157
.then(() => git(cloneArgs.concat(lp)))

lib/utils.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,3 @@
1-
const { basename } = require('path')
2-
31
const isWindows = opts => (opts.fakePlatform || process.platform) === 'win32'
42

5-
// wrap the target in quotes for Windows when using cmd(.exe) as a shell to
6-
// avoid clone failures for paths with spaces
7-
const escapePath = (gitPath, opts) => {
8-
const isCmd = opts.shell && (basename(opts.shell.toLowerCase(), '.exe') === 'cmd')
9-
if (isWindows(opts) && isCmd && !gitPath.startsWith('"')) {
10-
return `"${gitPath}"`
11-
}
12-
return gitPath
13-
}
14-
15-
exports.escapePath = escapePath
163
exports.isWindows = isWindows

lib/which.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
const { escapePath } = require('./utils.js')
21
const which = require('which')
32

43
let gitPath
@@ -13,5 +12,5 @@ module.exports = (opts = {}) => {
1312
if (!gitPath || opts.git === false) {
1413
return Object.assign(new Error('No git binary found in $PATH'), { code: 'ENOGIT' })
1514
}
16-
return escapePath(gitPath, opts)
15+
return gitPath
1716
}

test/clone.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,5 +253,8 @@ if ((process.platform) === 'win32') {
253253
)
254254
} else {
255255
t.test('cloning to folder with spaces with cmd as the shell not on windows', t =>
256-
t.rejects(clone(join(regularRepo, '.git'), 'HEAD', clonedRepoSpaces2, { fakePlatform: 'win32', shell: 'cmd' })))
256+
clone(join(regularRepo, '.git'), 'HEAD', clonedRepoSpaces2, { fakePlatform: 'win32', shell: 'cmd' })
257+
.then(() => revs(regularRepo))
258+
.then((r) => revs(clonedRepoSpaces2).then((r2) => t.same(Object.keys(r.shas), Object.keys(r2.shas))))
259+
)
257260
}

0 commit comments

Comments
 (0)