nixpkgs-suyu/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

27 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