Skip to content

Commit

Permalink
Do not allow git replacement objects by default (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs authored May 6, 2021
1 parent 94e2543 commit ab646cf
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 295 deletions.
2 changes: 1 addition & 1 deletion lib/clone.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const pickManifest = require('npm-pick-manifest')
const fs = require('fs')
const mkdirp = require('mkdirp')

module.exports = (repo, ref = 'HEAD', target = null, /* istanbul ignore next */ opts = {}) =>
module.exports = (repo, ref = 'HEAD', target = null, opts = {}) =>
revs(repo, opts).then(revs => clone(
repo,
revs,
Expand Down
11 changes: 8 additions & 3 deletions lib/spawn.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ module.exports = (gitArgs, opts = {}) => {

if (gitPath instanceof Error) { return Promise.reject(gitPath) }

// undocumented option, mostly only here for tests
const args = opts.allowReplace || gitArgs[0] === '--no-replace-objects'
? gitArgs
: ['--no-replace-objects', ...gitArgs]

const log = opts.log || procLog
let retry = opts.retry
if (retry === null || retry === undefined) {
Expand All @@ -22,11 +27,11 @@ module.exports = (gitArgs, opts = {}) => {
}
return promiseRetry((retry, number) => {
if (number !== 1) {
log.silly('pacote', `Retrying git command: ${
gitArgs.join(' ')} attempt # ${number}`)
log.silly('git', `Retrying git command: ${
args.join(' ')} attempt # ${number}`)
}

return spawn(gitPath, gitArgs, makeOpts(opts))
return spawn(gitPath, args, makeOpts(opts))
.catch(er => {
if (!shouldRetry(er.stderr, number)) {
throw er
Expand Down
284 changes: 0 additions & 284 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ab646cf

Please sign in to comment.