From b8658f629b598d9a5bb0acba2421e0ad99f67847 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Sun, 18 Jun 2017 13:42:39 +0200 Subject: [PATCH] fetchgit: support "git@server:repo" URLs Update the code that extracts the base name from a git repo URL so that it can deal with URLs like "git@server:repo". --- pkgs/build-support/fetchgit/default.nix | 3 ++- pkgs/build-support/fetchgit/nix-prefetch-git | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/fetchgit/default.nix b/pkgs/build-support/fetchgit/default.nix index a5f81ef17940..8e060b87ebd3 100644 --- a/pkgs/build-support/fetchgit/default.nix +++ b/pkgs/build-support/fetchgit/default.nix @@ -1,6 +1,7 @@ {stdenv, git, cacert}: let urlToName = url: rev: let - base = baseNameOf (stdenv.lib.removeSuffix "/" url); + inherit (stdenv.lib) removeSuffix splitString last; + base = last (splitString ":" (baseNameOf (removeSuffix "/" url))); matched = builtins.match "(.*).git" base; diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index 3d656eba5fff..9e4f346f7a52 100755 --- a/pkgs/build-support/fetchgit/nix-prefetch-git +++ b/pkgs/build-support/fetchgit/nix-prefetch-git @@ -120,9 +120,8 @@ hash_from_ref(){ url_to_name(){ local url=$1 local ref=$2 - # basename removes the / and .git suffixes local base - base=$(basename "$url" .git) + base=$(basename "$url" .git | cut -d: -f2) if [[ $ref =~ ^[a-z0-9]+$ ]]; then echo "$base-${ref:0:7}"