summary refs log tree commit diff
path: root/pkgs/build-support/fetchgit
diff options
context:
space:
mode:
authorVolth <volth@webmaster.ms>2017-06-26 12:56:00 +0000
committerVolth <volth@webmaster.ms>2017-07-04 20:22:13 +0000
commit535a6c3520c3e34c5d74008764d12165650ec4d4 (patch)
treeb8fe96e8f88537a7ea3d789e109bddb5b7ca5ce7 /pkgs/build-support/fetchgit
parentc73f0caea5f0822ea044b4f90de4b64706d91362 (diff)
downloadnixpkgs-535a6c3520c3e34c5d74008764d12165650ec4d4.tar
nixpkgs-535a6c3520c3e34c5d74008764d12165650ec4d4.tar.gz
nixpkgs-535a6c3520c3e34c5d74008764d12165650ec4d4.tar.bz2
nixpkgs-535a6c3520c3e34c5d74008764d12165650ec4d4.tar.lz
nixpkgs-535a6c3520c3e34c5d74008764d12165650ec4d4.tar.xz
nixpkgs-535a6c3520c3e34c5d74008764d12165650ec4d4.tar.zst
nixpkgs-535a6c3520c3e34c5d74008764d12165650ec4d4.zip
fetchFromGitHub: fix fetchSubmodules=true when revision is not hexadecimal
Diffstat (limited to 'pkgs/build-support/fetchgit')
-rw-r--r--pkgs/build-support/fetchgit/default.nix16
-rw-r--r--pkgs/build-support/fetchgit/gitrepotoname.nix14
-rwxr-xr-xpkgs/build-support/fetchgit/nix-prefetch-git4
3 files changed, 18 insertions, 16 deletions
diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix
index 8e060b87ebd..57afb1c4ab8 100644
--- a/pkgs/build-support/fetchgit/default.nix
+++ b/pkgs/build-support/fetchgit/default.nix
@@ -1,21 +1,9 @@
-{stdenv, git, cacert}: let
-  urlToName = url: rev: let
-    inherit (stdenv.lib) removeSuffix splitString last;
-    base = last (splitString ":" (baseNameOf (removeSuffix "/" url)));
+{stdenv, git, cacert, gitRepoToName}:
 
-    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 ? urlToName url rev
+, name ? gitRepoToName url rev
 , # Shell code executed after the file has been fetched
   # successfully. This can do things like check or transform the file.
   postFetch ? ""
diff --git a/pkgs/build-support/fetchgit/gitrepotoname.nix b/pkgs/build-support/fetchgit/gitrepotoname.nix
new file mode 100644
index 00000000000..9f4392c387f
--- /dev/null
+++ b/pkgs/build-support/fetchgit/gitrepotoname.nix
@@ -0,0 +1,14 @@
+{ lib }:
+
+urlOrRepo: rev: let
+  inherit (lib) removeSuffix splitString last;
+  base = last (splitString ":" (baseNameOf (removeSuffix "/" urlOrRepo)));
+
+  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}"
\ No newline at end of file
diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git
index 9e4f346f7a5..c3ba15d5902 100755
--- a/pkgs/build-support/fetchgit/nix-prefetch-git
+++ b/pkgs/build-support/fetchgit/nix-prefetch-git
@@ -282,8 +282,8 @@ _clone_user_rev() {
             if test -z "$(echo "$rev" | tr -d 0123456789abcdef)"; then
                 clone "$dir" "$url" "$rev" "" 1>&2
             else
-                echo 1>&2 "Bad commit hash or bad reference."
-                exit 1
+                # if revision is not hexadecimal it might be a tag
+                clone "$dir" "$url" "" "refs/tags/$rev" 1>&2
             fi;;
     esac