buildRustPackage: fix failure due to branch names with slashes

Fixes #11237
This commit is contained in:
Ricardo M. Correia 2015-11-24 20:42:31 +01:00
parent 373da3b815
commit 799f0f1f23
1 changed files with 9 additions and 5 deletions

View File

@ -115,14 +115,18 @@ rm -rf $out/registry/index/*
# Make git DBs deterministic # Make git DBs deterministic
# TODO: test with git submodules # TODO: test with git submodules
[[ ! -d $out/git/checkouts ]] || (cd $out/git/checkouts && for name in *; do [[ ! -d $out/git/checkouts ]] || (cd $out/git/checkouts && for name in *; do
cd "$out/git/checkouts/$name"
revs="" revs=""
for branch in *; do cd "$out/git/checkouts/$name"
cd "$branch" while read dir; do
# extract substring: [dir = "./xxx/yyy/.git"] => [branch = "xxx/yyy"]
branch="${dir:2:$((${#dir}-7))}"
cd "$out/git/checkouts/$name/$branch"
rev="$(git rev-parse HEAD)" rev="$(git rev-parse HEAD)"
revs="$revs $rev" revs="$revs $rev"
cd .. done < <(find . -type d -name .git -print)
done
echo "List of revs to keep for git db $name: $revs"
( (
# The following code was adapted from nix-prefetch-git # The following code was adapted from nix-prefetch-git