Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
Merge 8c795c9 into cf3fc26
Browse files Browse the repository at this point in the history
  • Loading branch information
iarna committed Apr 16, 2017
2 parents cf3fc26 + 8c795c9 commit 67485ce
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 19 deletions.
20 changes: 10 additions & 10 deletions lib/handlers/git/manifest.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const BB = require('bluebird')

const git = require('../../util/git')
const normalizeGitUrl = require('normalize-git-url')
const optCheck = require('../../util/opt-check')
const pickManifest = require('../../registry/pick-manifest')
const semver = require('semver')
Expand Down Expand Up @@ -36,30 +35,31 @@ function hostedManifest (spec, opts) {
}

function plainManifest (repo, spec, opts) {
const normed = normalizeGitUrl(repo)
const rawRef = decodeURIComponent(normed.branch)
const rawRef = spec.gitCommittish
return resolve(
normed.url, rawRef, spec.name, opts
repo, rawRef, spec.name, opts
).then(ref => {
if (ref) {
const resolved = spec.saveSpec.replace(/#.*/, `#${ref.sha}`)
return {
_repo: normed.url,
_resolved: `${normed.url}#${ref.sha}`,
_repo: repo,
_resolved: resolved,
_spec: spec,
_ref: ref,
_rawRef: rawRef,
_uniqueResolved: `${normed.url}#${ref.sha}`
_uniqueResolved: resolved
}
} else {
// We're SOL and need a full clone :(
//
// If we're confident enough that `rawRef` is a commit SHA,
// then we can at least get `finalize-manifest` to cache its result.
const resolved = spec.saveSpec.replace(/#.*/, `#${rawRef}`)
return {
_repo: normed.url,
_repo: repo,
_rawRef: rawRef,
_resolved: rawRef.match(/^[a-f0-9]{40}$/) && `${normed.url}#${rawRef}`,
_uniqueResolved: rawRef.match(/^[a-f0-9]{40}$/) && `${normed.url}#${rawRef}`
_resolved: rawRef.match(/^[a-f0-9]{40}$/) && resolved,
_uniqueResolved: rawRef.match(/^[a-f0-9]{40}$/) && resolved
}
}
})
Expand Down
9 changes: 7 additions & 2 deletions lib/handlers/git/tarball.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ function fromManifest (manifest, spec, opts) {
opts = optCheck(opts)
let streamError
const stream = new PassThrough().on('error', e => { streamError = e })
const cacheName = manifest._resolved || spec.saveSpec || spec.fetchSpec
const cacheStream = (
opts.cache &&
cache.get.stream(
opts.cache, cache.key('packed-dir', manifest._resolved), opts
opts.cache, cache.key('packed-dir', cacheName), opts
)
)
cacheStream.pipe(stream)
Expand All @@ -50,7 +51,11 @@ function fromManifest (manifest, spec, opts) {
manifest._repo, manifest._ref, manifest._rawRef, tmp, opts
).then(HEAD => {
if (streamError) { throw streamError }
return packDir(manifest, manifest._resolved, tmp, stream, opts)
if (!manifest._resolved) {
manifest._resolved = spec.saveSpec.replace(/#.*/, `#${HEAD}`)
manifest._uniqueResolved = manifest._resolved
}
return packDir(manifest, cacheName, tmp, stream, opts)
})
}).catch(err => stream.emit('error', err))
}
Expand Down
9 changes: 3 additions & 6 deletions lib/util/git.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ const execFileAsync = BB.promisify(cp.execFile, {
})
const finished = BB.promisify(require('mississippi').finished)
const LRU = require('lru-cache')
const normalizeGitUrl = require('normalize-git-url')
const optCheck = require('./opt-check')
const osenv = require('osenv')
const path = require('path')
Expand Down Expand Up @@ -51,13 +50,12 @@ try {
module.exports.clone = fullClone
function fullClone (repo, committish, target, opts) {
opts = optCheck(opts)
const normed = normalizeGitUrl(repo)
const gitArgs = [
'clone',
'-q',
// Mainly for windows, but no harm done
'-c', 'core.longpaths=true',
normed.url,
repo,
target
]
return execGit(gitArgs, {
Expand All @@ -74,15 +72,14 @@ function fullClone (repo, committish, target, opts) {
module.exports.shallow = shallowClone
function shallowClone (repo, branch, target, opts) {
opts = optCheck(opts)
const normed = normalizeGitUrl(repo)
const gitArgs = [
'clone',
'--depth=1',
'-q',
'-b', branch,
// Mainly for windows, but no harm done
'-c', 'core.longpaths=true',
normed.url,
repo,
target
]
return execGit(gitArgs, {
Expand All @@ -107,7 +104,7 @@ function updateSubmodules (localRepo, opts) {

function headSha (repo, opts) {
opts = optCheck(opts)
return execGit(['rev-parse', '--revs-only', 'HEAD', repo], {}, opts).spread(stdout => {
return execGit(['rev-parse', '--revs-only', 'HEAD'], {cwd: repo}, opts).spread(stdout => {
return stdout.trim()
})
}
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
"make-fetch-happen": "^2.2.2",
"minimatch": "^3.0.3",
"mississippi": "^1.2.0",
"normalize-git-url": "^3.0.2",
"normalize-package-data": "^2.3.6",
"npm-package-arg": "^5.0.0",
"osenv": "^0.1.4",
Expand Down

0 comments on commit 67485ce

Please sign in to comment.