1// add a sha to a git remote url spec 2const addGitSha = (spec, sha) => { 3 if (spec.hosted) { 4 const h = spec.hosted 5 const opt = { noCommittish: true } 6 const base = h.https && h.auth ? h.https(opt) : h.shortcut(opt) 7 8 return `${base}#${sha}` 9 } else { 10 // don't use new URL for this, because it doesn't handle scp urls 11 return spec.rawSpec.replace(/#.*$/, '') + `#${sha}` 12 } 13} 14 15module.exports = addGitSha 16