diff --git a/lib/packagefetcher/git.js b/lib/packagefetcher/git.js index 8dac1d1..c9cadac 100644 --- a/lib/packagefetcher/git.js +++ b/lib/packagefetcher/git.js @@ -40,11 +40,14 @@ function fetchMetaDataFromGit(baseDir, dependencyName, versionSpec, callback) { break; } - var commitIsh = parsedUrl.hash; - if(commitIsh === null) // Use master as default commitish - commitIsh = "master"; - else - commitIsh = commitIsh.substr(1); + /* Compose the commitIsh out of the hash suffix, if applicable */ + var commitIsh; + + if(parsedUrl.hash !== null) { + commitIsh = parsedUrl.hash.substr(1); + } else { + commitIsh = null; + } delete parsedUrl.hash; @@ -107,11 +110,18 @@ function fetchMetaDataFromGit(baseDir, dependencyName, versionSpec, callback) { }, function(callback) { + var branch; - process.stderr.write("Parsing the revision of commitish: "+commitIsh+"\n"); + if(commitIsh === null) { + branch = "HEAD"; + } else { + branch = commitIsh; + } + + process.stderr.write("Parsing the revision of commitish: "+branch+"\n"); /* Check whether the given commitish corresponds to a hash */ - var gitRevParse = child_process.spawn("git", [ "rev-parse", commitIsh ], { + var gitRevParse = child_process.spawn("git", [ "rev-parse", branch ], { cwd: repositoryDir }); @@ -130,7 +140,7 @@ function fetchMetaDataFromGit(baseDir, dependencyName, versionSpec, callback) { }, function(callback) { - if(rev == "") { + if(commitIsh !== null && rev == "") { process.stderr.write("Parsing the revision of commitish: origin/"+commitIsh+"\n"); /* Resolve the hash of the branch/tag */ @@ -156,22 +166,26 @@ function fetchMetaDataFromGit(baseDir, dependencyName, versionSpec, callback) { }, function(callback) { - rev = rev.substr(0, rev.length - 1); - - process.stderr.write("Checking out revision: "+rev+"\n"); - - /* Check out the corresponding revision */ - var gitCheckout = child_process.spawn("git", [ "checkout", rev ], { - cwd: repositoryDir, - stdio: "inherit" - }); - - gitCheckout.on("close", function(code) { - if(code == 0) - callback(null); - else - callback("git checkout exited with status: "+code); - }); + if(rev == "") { + callback(null); + } else { + rev = rev.substr(0, rev.length - 1); + + process.stderr.write("Checking out revision: "+rev+"\n"); + + /* Check out the corresponding revision */ + var gitCheckout = child_process.spawn("git", [ "checkout", rev ], { + cwd: repositoryDir, + stdio: "inherit" + }); + + gitCheckout.on("close", function(code) { + if(code == 0) + callback(null); + else + callback("git checkout exited with status: "+code); + }); + } }, function(callback) { diff --git a/lib/packageset.js b/lib/packageset.js index ffce42a..97db61c 100644 --- a/lib/packageset.js +++ b/lib/packageset.js @@ -29,6 +29,17 @@ function PackageSet(registryURL, outputDir) { this.sources = {}; } +function composeGitURL(baseURL, parsedUrl) { + var hashComponent; + + if(parsedUrl.hash === null) + hashComponent = ""; + else + hashComponent = parsedUrl.hash; + + return baseURL + "/" + parsedUrl.host + parsedUrl.path + hashComponent; +} + /** * Fetches package metadata from an external source that is determined by the * version specifier, so that a partial Nix expression can be generated that @@ -55,13 +66,13 @@ PackageSet.prototype.fetchMetaData = function(baseDir, dependencyName, versionSp if(parsedVersionSpec !== null) { // If the version is valid semver range, fetch the package from the NPM registry fetchMetaDataFromNPMRegistry(baseDir, dependencyName, parsedVersionSpec, this.registryURL, callback); } else if(parsedUrl.protocol == "github:") { // If the version is a GitHub repository, compose the corresponding Git URL and do a Git checkout - fetchMetaDataFromGit(baseDir, dependencyName, "git://github.com/"+parsedUrl.host+parsedUrl.path, callback); + fetchMetaDataFromGit(baseDir, dependencyName, composeGitURL("git://github.com", parsedUrl), callback); } else if(parsedUrl.protocol == "gist:") { // If the version is a GitHub gist repository, compose the corresponding Git URL and do a Git checkout - fetchMetaDataFromGit(baseDir, dependencyName, "https://gist.github.com/"+parsedUrl.host+parsedUrl.path, callback); + fetchMetaDataFromGit(baseDir, dependencyName, composeGitURL("https://gist.github.com", parsedUrl), callback); } else if(parsedUrl.protocol == "bitbucket:") { // If the version is a Bitbucket repository, compose the corresponding Git URL and do a Git checkout - fetchMetaDataFromGit(baseDir, dependencyName, "git://bitbucket.org/"+parsedUrl.host+parsedUrl.path, callback); + fetchMetaDataFromGit(baseDir, dependencyName, composeGitURL("git://bitbucket.org", parsedUrl), callback); } else if(parsedUrl.protocol == "gitlab:") { // If the version is a Gitlab repository, compose the corresponding Git URL and do a Git checkout - fetchMetaDataFromGit(baseDir, dependencyName, "git://gitlab.com/"+parsedUrl.host+parsedUrl.path, callback); + fetchMetaDataFromGit(baseDir, dependencyName, composeGitURL("git://gitlab.com", parsedUrl), callback); } else if(typeof parsedUrl.protocol == "string" && parsedUrl.protocol.substr(0, 3) == "git") { // If the version is a Git URL do a Git checkout fetchMetaDataFromGit(baseDir, dependencyName, versionSpec, callback); } else if(parsedUrl.protocol == "http:" || parsedUrl.protocol == "https:") { // If the version is an HTTP URL do a download diff --git a/node-packages.nix b/node-packages.nix index ab84715..9754744 100644 --- a/node-packages.nix +++ b/node-packages.nix @@ -202,13 +202,13 @@ let sha1 = "2d46fa874337af9498a2f12bb43d8d0be4a36873"; }; }; - "inherits-2.0.1" = { + "inherits-2.0.2" = { name = "inherits"; packageName = "inherits"; - version = "2.0.1"; + version = "2.0.2"; src = fetchurl { - url = "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"; - sha1 = "b17d08d326b4423e568eff719f91b0b1cbdf69f1"; + url = "https://registry.npmjs.org/inherits/-/inherits-2.0.2.tgz"; + sha1 = "7880e686ae72d327c3e7cdb406c3b71ad12b36b8"; }; }; "typedarray-0.0.6" = { @@ -1350,7 +1350,7 @@ let sources."chownr-1.0.1" (sources."concat-stream-1.5.2" // { dependencies = [ - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."typedarray-0.0.6" (sources."readable-stream-2.0.6" // { dependencies = [ @@ -1409,7 +1409,7 @@ let (sources."readable-stream-2.0.6" // { dependencies = [ sources."core-util-is-1.0.2" - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."isarray-1.0.0" sources."process-nextick-args-1.0.7" sources."string_decoder-0.10.31" @@ -1542,7 +1542,7 @@ let sources."wrappy-1.0.2" ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" (sources."minimatch-3.0.3" // { dependencies = [ (sources."brace-expansion-1.1.6" // { @@ -1568,7 +1568,7 @@ let dependencies = [ sources."buffer-shims-1.0.0" sources."core-util-is-1.0.2" - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."isarray-1.0.0" sources."process-nextick-args-1.0.7" sources."string_decoder-0.10.31" @@ -1619,7 +1619,7 @@ let sources."proto-list-1.2.4" ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."ini-1.3.4" (sources."mkdirp-0.5.1" // { dependencies = [ @@ -1689,7 +1689,7 @@ let }) ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" ]; }) (sources."temp-0.8.3" // { diff --git a/release.nix b/release.nix index f4984c5..5c735a9 100644 --- a/release.nix +++ b/release.nix @@ -56,11 +56,6 @@ rec { in map (name: builtins.getAttr name tests_) (builtins.attrNames tests_) ) systems) - ++ pkgs.lib.flatten (map (system: - let - tests_ = tests."${system}".grunt; - in - map (name: builtins.getAttr name tests_) (builtins.attrNames tests_) - ) systems); + ++ map (system: tests."${system}".grunt) systems; }; } diff --git a/tests/grunt/node-packages.nix b/tests/grunt/node-packages.nix index d2e6349..15e20b2 100644 --- a/tests/grunt/node-packages.nix +++ b/tests/grunt/node-packages.nix @@ -580,13 +580,13 @@ let sha1 = "db3204cd5a9de2e6cd890b85c6e2f66bcf4f620a"; }; }; - "inherits-2.0.1" = { + "inherits-2.0.2" = { name = "inherits"; packageName = "inherits"; - version = "2.0.1"; + version = "2.0.2"; src = fetchurl { - url = "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"; - sha1 = "b17d08d326b4423e568eff719f91b0b1cbdf69f1"; + url = "https://registry.npmjs.org/inherits/-/inherits-2.0.2.tgz"; + sha1 = "7880e686ae72d327c3e7cdb406c3b71ad12b36b8"; }; }; "once-1.4.0" = { @@ -1407,7 +1407,7 @@ let sources."wrappy-1.0.2" ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" @@ -1425,7 +1425,7 @@ let sources."wrappy-1.0.2" ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" @@ -1545,7 +1545,7 @@ let sources."wrappy-1.0.2" ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" @@ -1581,7 +1581,7 @@ let sources."core-util-is-1.0.2" sources."isarray-0.0.1" sources."string_decoder-0.10.31" - sources."inherits-2.0.1" + sources."inherits-2.0.2" ]; }) sources."entities-1.0.0" @@ -1619,7 +1619,7 @@ let sources."wrappy-1.0.2" ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" @@ -1653,7 +1653,7 @@ let sources."depd-1.1.0" (sources."http-errors-1.3.1" // { dependencies = [ - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."statuses-1.3.0" ]; }) diff --git a/tests/grunt/supplement.nix b/tests/grunt/supplement.nix index 5d8decf..054cdd4 100644 --- a/tests/grunt/supplement.nix +++ b/tests/grunt/supplement.nix @@ -580,13 +580,13 @@ let sha1 = "db3204cd5a9de2e6cd890b85c6e2f66bcf4f620a"; }; }; - "inherits-2.0.1" = { + "inherits-2.0.2" = { name = "inherits"; packageName = "inherits"; - version = "2.0.1"; + version = "2.0.2"; src = fetchurl { - url = "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz"; - sha1 = "b17d08d326b4423e568eff719f91b0b1cbdf69f1"; + url = "https://registry.npmjs.org/inherits/-/inherits-2.0.2.tgz"; + sha1 = "7880e686ae72d327c3e7cdb406c3b71ad12b36b8"; }; }; "once-1.4.0" = { @@ -1285,7 +1285,7 @@ in sources."wrappy-1.0.2" ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" (sources."minimatch-3.0.3" // { dependencies = [ (sources."brace-expansion-1.1.6" // { diff --git a/tests/node-packages-v4.nix b/tests/node-packages-v4.nix index cbbd320..d1627eb 100644 --- a/tests/node-packages-v4.nix +++ b/tests/node-packages-v4.nix @@ -571,6 +571,15 @@ let sha1 = "dded45cc18256d51ed40aec142489d5c61026d28"; }; }; + "inherits-2.0.2" = { + name = "inherits"; + packageName = "inherits"; + version = "2.0.2"; + src = fetchurl { + url = "https://registry.npmjs.org/inherits/-/inherits-2.0.2.tgz"; + sha1 = "7880e686ae72d327c3e7cdb406c3b71ad12b36b8"; + }; + }; "send-0.13.2" = { name = "send"; packageName = "send"; @@ -2112,7 +2121,7 @@ in sources."destroy-1.0.3" (sources."http-errors-1.3.1" // { dependencies = [ - sources."inherits-2.0.1" + sources."inherits-2.0.2" ]; }) sources."mime-1.3.4" @@ -2129,7 +2138,7 @@ in sources."destroy-1.0.4" (sources."http-errors-1.3.1" // { dependencies = [ - sources."inherits-2.0.1" + sources."inherits-2.0.2" ]; }) sources."mime-1.3.4" @@ -2350,7 +2359,7 @@ in sources."wrappy-1.0.2" ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" (sources."minimatch-3.0.3" // { dependencies = [ (sources."brace-expansion-1.1.6" // { @@ -2467,7 +2476,7 @@ in (sources."readable-stream-2.0.6" // { dependencies = [ sources."core-util-is-1.0.2" - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."isarray-1.0.0" sources."process-nextick-args-1.0.7" sources."string_decoder-0.10.31" @@ -2604,7 +2613,7 @@ in dependencies = [ sources."buffer-shims-1.0.0" sources."core-util-is-1.0.2" - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."isarray-1.0.0" sources."process-nextick-args-1.0.7" sources."string_decoder-0.10.31" @@ -2664,7 +2673,7 @@ in sources."wrappy-1.0.2" ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" @@ -2684,7 +2693,7 @@ in sources."graceful-fs-4.1.6" ]; }) - sources."inherits-2.0.1" + sources."inherits-2.0.2" ]; }) (sources."tar-pack-3.1.4" // { @@ -2697,12 +2706,12 @@ in (sources."fstream-1.0.10" // { dependencies = [ sources."graceful-fs-4.1.6" - sources."inherits-2.0.1" + sources."inherits-2.0.2" ]; }) (sources."fstream-ignore-1.0.5" // { dependencies = [ - sources."inherits-2.0.1" + sources."inherits-2.0.2" ]; }) (sources."once-1.3.3" // { @@ -2714,7 +2723,7 @@ in dependencies = [ sources."buffer-shims-1.0.0" sources."core-util-is-1.0.2" - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."isarray-1.0.0" sources."process-nextick-args-1.0.7" sources."string_decoder-0.10.31" diff --git a/tests/node-packages-v5.nix b/tests/node-packages-v5.nix index ee2b39d..ef24d63 100644 --- a/tests/node-packages-v5.nix +++ b/tests/node-packages-v5.nix @@ -571,6 +571,15 @@ let sha1 = "dded45cc18256d51ed40aec142489d5c61026d28"; }; }; + "inherits-2.0.2" = { + name = "inherits"; + packageName = "inherits"; + version = "2.0.2"; + src = fetchurl { + url = "https://registry.npmjs.org/inherits/-/inherits-2.0.2.tgz"; + sha1 = "7880e686ae72d327c3e7cdb406c3b71ad12b36b8"; + }; + }; "send-0.13.2" = { name = "send"; packageName = "send"; @@ -2062,7 +2071,7 @@ in sources."http-errors-1.3.1" sources."mime-1.3.4" sources."statuses-1.2.1" - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."media-typer-0.3.0" ]; buildInputs = globalBuildInputs; @@ -2218,7 +2227,7 @@ in sources."resolve-1.1.7" sources."glob-5.0.15" sources."inflight-1.0.5" - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."minimatch-3.0.3" sources."once-1.4.0" sources."path-is-absolute-1.0.0" @@ -2321,7 +2330,7 @@ in sources."tunnel-agent-0.4.3" sources."readable-stream-2.0.6" sources."core-util-is-1.0.2" - sources."inherits-2.0.1" + sources."inherits-2.0.2" sources."isarray-1.0.0" sources."process-nextick-args-1.0.7" sources."string_decoder-0.10.31"