Merge: more compatibility for git* fetchers
They're additional commits from #26877. Changing names of the fetched stuff was changing very many hashes, and I think it's better to avoid that for the moment to reduce work needed by nixpkgs users. The fetchers are expected to be commonly used even outside nixpkgs, and the current naming wasn't that bad usually. (commit analogical to d10c3cc5eedf58e80e2; I haven't noticed the part of the PR has already got to master)
This commit is contained in:
commit
986c17727e
@ -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 ? ""
|
||||
|
@ -1,14 +1,19 @@
|
||||
{ lib }:
|
||||
|
||||
urlOrRepo: rev: let
|
||||
inherit (lib) removeSuffix splitString last;
|
||||
base = last (splitString ":" (baseNameOf (removeSuffix "/" urlOrRepo)));
|
||||
let
|
||||
inherit (lib) removeSuffix hasPrefix removePrefix splitString stringToCharacters concatMapStrings last elem;
|
||||
|
||||
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}"
|
||||
allowedChars = stringToCharacters "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+-._?=";
|
||||
sanitizeStoreName = s:
|
||||
let
|
||||
s' = concatMapStrings (c: if elem c allowedChars then c else "") (stringToCharacters s);
|
||||
s'' = if hasPrefix "." s' then "_${removePrefix "." s'}" else s';
|
||||
in
|
||||
s'';
|
||||
in
|
||||
urlOrRepo: rev:
|
||||
let
|
||||
repo' = last (splitString ":" (baseNameOf (removeSuffix ".git" (removeSuffix "/" urlOrRepo))));
|
||||
rev' = baseNameOf rev;
|
||||
in
|
||||
"${sanitizeStoreName repo'}-${sanitizeStoreName rev'}-src"
|
||||
|
Loading…
Reference in New Issue
Block a user