yarn2nix: handle codeload.github.com uris in IFD mode (#136922)

This commit is contained in:
Yuka 2021-10-08 14:18:57 +02:00 committed by GitHub
parent 839fb3f523
commit b27d18a412
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 5 deletions

View File

@ -53,7 +53,7 @@ if (json.type !== 'success') {
// Check for missing hashes in the yarn.lock and patch if necessary
const pkgs = R.pipe(
let pkgs = R.pipe(
mapObjIndexedReturnArray((value, key) => ({
...value,
nameWithVersion: key,
@ -61,10 +61,10 @@ const pkgs = R.pipe(
R.uniqBy(R.prop('resolved')),
)(json.object)
const fixedPkgsPromises = R.map(fixPkgAddMissingSha1, pkgs)
;(async () => {
const fixedPkgs = await Promise.all(fixedPkgsPromises)
if (!options['--no-patch']) {
pkgs = await R.map(fixPkgAddMissingSha1, pkgs)
}
const origJson = lockfile.parse(data)
@ -81,7 +81,7 @@ const fixedPkgsPromises = R.map(fixPkgAddMissingSha1, pkgs)
if (!options['--no-nix']) {
// print to stdout
console.log(generateNix(fixedPkgs, options['--builtin-fetchgit']))
console.log(generateNix(pkgs, options['--builtin-fetchgit']))
}
})().catch(error => {
console.error(error)

View File

@ -80,6 +80,16 @@ function fetchLockedDep(builtinFetchGit) {
const fileName = urlToName(url)
if (resolved.startsWith('https://codeload.github.com/')) {
const s = resolved.split('/')
const githubUrl = `https://github.com/${s[3]}/${s[4]}.git`
const githubRev = s[6]
const [_, branch] = nameWithVersion.split('#')
return fetchgit(fileName, githubUrl, rev, branch || 'master', builtinFetchGit)
}
if (url.startsWith('git+') || url.startsWith("git:")) {
const rev = sha1OrRev