1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 23:20:55 +00:00
nixpkgs/pkgs/build-support/fetchgit/builder.sh
Florian Friesdorf a8c3649dd4 fetchgit builder rewrite to handle more cases
The old builder failed for:
- remote HEAD != master
- local repositories

svn path=/nixpkgs/trunk/; revision=26984
2011-04-27 03:00:47 +00:00

28 lines
592 B
Bash

source $stdenv/setup
header "exporting $url (rev $rev) into $out"
git init $out
cd $out
git remote add origin "$url"
git fetch origin
git remote set-head origin -a
# If no revision was specified, the remote HEAD will be used
git checkout -b __nixos_build__ origin/HEAD
if test -n "$rev"; then
echo "Trying to checkout: $rev"
parsed_rev=$(
git rev-parse --verify "$rev" 2>/dev/null ||
git rev-parse --verify origin/"$rev" 2>/dev/null
)
git reset --hard $parsed_rev
fi
if test -z "$leaveDotGit"; then
find $out -name .git\* | xargs rm -rf
fi
stopNest