mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 23:13:19 +00:00
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:
parent
909fb246fd
commit
b8658f629b
@ -1,6 +1,7 @@
|
|||||||
{stdenv, git, cacert}: let
|
{stdenv, git, cacert}: let
|
||||||
urlToName = url: rev: 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;
|
matched = builtins.match "(.*).git" base;
|
||||||
|
|
||||||
|
@ -120,9 +120,8 @@ hash_from_ref(){
|
|||||||
url_to_name(){
|
url_to_name(){
|
||||||
local url=$1
|
local url=$1
|
||||||
local ref=$2
|
local ref=$2
|
||||||
# basename removes the / and .git suffixes
|
|
||||||
local base
|
local base
|
||||||
base=$(basename "$url" .git)
|
base=$(basename "$url" .git | cut -d: -f2)
|
||||||
|
|
||||||
if [[ $ref =~ ^[a-z0-9]+$ ]]; then
|
if [[ $ref =~ ^[a-z0-9]+$ ]]; then
|
||||||
echo "$base-${ref:0:7}"
|
echo "$base-${ref:0:7}"
|
||||||
|
Loading…
Reference in New Issue
Block a user