forked from mirrors/nixpkgs
fetchgit: give output a nicer name
Instead of git-export, we get the basename of the repo, plus the shortrev if the commit-ish is a rev.
This commit is contained in:
parent
fdb785f4d1
commit
a8603605aa
|
@ -1,6 +1,20 @@
|
||||||
{stdenv, git, cacert}:
|
{stdenv, git, cacert}: let
|
||||||
{url, rev ? "HEAD", md5 ? "", sha256 ? "", leaveDotGit ? false, fetchSubmodules ? true
|
urlToName = url: rev: let
|
||||||
, name ? "git-export"
|
base = baseNameOf url;
|
||||||
|
|
||||||
|
matched = (builtins.match or (x: y:
|
||||||
|
abort "This version of fetchgit requires Nix >= 1.8, please upgrade!"
|
||||||
|
)) "(.*).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 ? false
|
||||||
|
, fetchSubmodules ? true
|
||||||
|
, name ? urlToName url rev
|
||||||
}:
|
}:
|
||||||
|
|
||||||
/* NOTE:
|
/* NOTE:
|
||||||
|
|
Loading…
Reference in a new issue