mirror of
https://github.com/nodejs/node.git
synced 2025-05-15 05:00:15 +00:00

PR-URL: https://github.com/nodejs/node/pull/37496 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Michaël Zasso <targos@protonmail.com> Reviewed-By: Richard Lau <rlau@redhat.com> Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Beth Griggs <bgriggs@redhat.com>
16 lines
427 B
JavaScript
16 lines
427 B
JavaScript
// add a sha to a git remote url spec
|
|
const addGitSha = (spec, sha) => {
|
|
if (spec.hosted) {
|
|
const h = spec.hosted
|
|
const opt = { noCommittish: true }
|
|
const base = h.https && h.auth ? h.https(opt) : h.shortcut(opt)
|
|
|
|
return `${base}#${sha}`
|
|
} else {
|
|
// don't use new URL for this, because it doesn't handle scp urls
|
|
return spec.rawSpec.replace(/#.*$/, '') + `#${sha}`
|
|
}
|
|
}
|
|
|
|
module.exports = addGitSha
|