diff options
author | Volth <volth@webmaster.ms> | 2017-07-05 16:01:26 +0000 |
---|---|---|
committer | Volth <volth@webmaster.ms> | 2017-07-05 16:01:26 +0000 |
commit | ab8dd33e5cda3abe78d244f23e6097cd3e3bca4e (patch) | |
tree | 8e2de60d863683934016ee674a2b59ee0cd56c45 | |
parent | e7521e289ccbcba8928a0c0a2220fbbb35716556 (diff) |
support old naming, just add escaping of unsafe chars
-rw-r--r-- | pkgs/build-support/fetchgit/default.nix | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index 57afb1c4ab871..8e060b87ebd30 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -1,9 +1,21 @@ -{stdenv, git, cacert, gitRepoToName}: +{stdenv, git, cacert}: let + urlToName = url: rev: let + inherit (stdenv.lib) removeSuffix splitString last; + base = last (splitString ":" (baseNameOf (removeSuffix "/" url))); + matched = builtins.match "(.*).git" base; + + short = builtins.substring 0 7 rev; + + appendShort = if (builtins.match "[a-f0-9]*" rev) != null + then "-${short}" + else ""; + in "${if matched == null then base else builtins.head matched}${appendShort}"; +in { url, rev ? "HEAD", md5 ? "", sha256 ? "", leaveDotGit ? deepClone , fetchSubmodules ? true, deepClone ? false , branchName ? null -, name ? gitRepoToName url rev +, name ? urlToName url rev , # Shell code executed after the file has been fetched # successfully. This can do things like check or transform the file. postFetch ? "" |