Skip to content

Commit 85b269b

Browse files
committedApr 6, 2018
fix(git): make full clones do a full mirror
Fixes: npm/npm#16907
1 parent 757bee1 commit 85b269b

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed
 

‎lib/util/git.js

+5-7
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,14 @@ try {
7070
module.exports.clone = fullClone
7171
function fullClone (repo, committish, target, opts) {
7272
opts = optCheck(opts)
73-
const gitArgs = ['clone', '-q', repo, target]
73+
const gitArgs = ['clone', '--mirror', '-q', repo, path.join(target, '.git')]
7474
if (process.platform === 'win32') {
7575
gitArgs.push('--config', 'core.longpaths=true')
7676
}
77-
return execGit(gitArgs, {
78-
cwd: path.dirname(target)
79-
}, opts).then(() => {
80-
return committish && execGit(['checkout', committish], {
81-
cwd: target
82-
})
77+
return execGit(gitArgs, {cwd: target}).then(() => {
78+
return execGit(['init'], {cwd: target})
79+
}).then(() => {
80+
return execGit(['checkout', committish || 'HEAD'], {cwd: target})
8381
}).then(() => {
8482
return updateSubmodules(target, opts)
8583
}).then(() => headSha(target, opts))

0 commit comments

Comments
 (0)
Please sign in to comment.