Skip to content

Commit

Permalink
chore: refactor clone tests
Browse files Browse the repository at this point in the history
May start to help us debug windows CI timeouts
  • Loading branch information
wraithgar committed Feb 15, 2022
1 parent 57e86f6 commit 01f1330
Show file tree
Hide file tree
Showing 3 changed files with 220 additions and 243 deletions.
8 changes: 4 additions & 4 deletions lib/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const other = (repo, revDoc, target, opts) => {
const git = (args) => spawn(args, { ...opts, cwd: target })
return mkdirp(target)
.then(() => git(['init']))
.then(() => isWindows(opts)
.then(() => isWindows()
? git(['config', '--local', '--add', 'core.longpaths', 'true'])
: null)
.then(() => git(['remote', 'add', 'origin', repo]))
Expand All @@ -118,7 +118,7 @@ const branch = (repo, revDoc, target, opts) => {
if (maybeShallow(repo, opts)) {
args.push('--depth=1')
}
if (isWindows(opts)) {
if (isWindows()) {
args.push('--config', 'core.longpaths=true')
}
return spawn(args, opts).then(() => revDoc.sha)
Expand All @@ -135,7 +135,7 @@ const plain = (repo, revDoc, target, opts) => {
if (maybeShallow(repo, opts)) {
args.push('--depth=1')
}
if (isWindows(opts)) {
if (isWindows()) {
args.push('--config', 'core.longpaths=true')
}
return spawn(args, opts).then(() => revDoc.sha)
Expand All @@ -158,7 +158,7 @@ const updateSubmodules = (target, opts) => new Promise(resolve =>
const unresolved = (repo, ref, target, opts) => {
// can't do this one shallowly, because the ref isn't advertised
// but we can avoid checking out the working dir twice, at least
const lp = isWindows(opts) ? ['--config', 'core.longpaths=true'] : []
const lp = isWindows() ? ['--config', 'core.longpaths=true'] : []
const cloneArgs = ['clone', '--mirror', '-q', repo, target + '/.git']
const git = (args) => spawn(args, { ...opts, cwd: target })
return mkdirp(target)
Expand Down
5 changes: 2 additions & 3 deletions lib/utils.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
const isWindows = opts => (opts.fakePlatform || process.platform) === 'win32'

exports.isWindows = isWindows
// returns as a function so we can override it in tests
exports.isWindows = () => process.platform === 'win32'
Loading

0 comments on commit 01f1330

Please sign in to comment.