3
0
Fork 0
forked from mirrors/nixpkgs

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".
This commit is contained in:
Bjørn Forsman 2017-06-18 13:42:39 +02:00
parent 909fb246fd
commit b8658f629b
2 changed files with 3 additions and 3 deletions

View file

@ -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;

View file

@ -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}"