mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-01-22 14:45:27 +00:00
fetchgit builder to handle broken remotes without a HEAD
svn path=/nixpkgs/trunk/; revision=27521
This commit is contained in:
parent
edd3c49119
commit
ee731974e9
|
@ -1,3 +1,6 @@
|
||||||
|
# tested so far with:
|
||||||
|
# - no revision specified and remote has a HEAD which is used
|
||||||
|
# - revision specified and remote has a HEAD
|
||||||
source $stdenv/setup
|
source $stdenv/setup
|
||||||
|
|
||||||
header "exporting $url (rev $rev) into $out"
|
header "exporting $url (rev $rev) into $out"
|
||||||
|
@ -6,10 +9,8 @@ git init $out
|
||||||
cd $out
|
cd $out
|
||||||
git remote add origin "$url"
|
git remote add origin "$url"
|
||||||
git fetch origin
|
git fetch origin
|
||||||
git remote set-head origin -a
|
git remote set-head origin -a || (
|
||||||
|
test -n $rev && echo "that's ok, we want $rev" || exit 1)
|
||||||
# If no revision was specified, the remote HEAD will be used
|
|
||||||
git checkout -b __nixos_build__ origin/HEAD
|
|
||||||
|
|
||||||
if test -n "$rev"; then
|
if test -n "$rev"; then
|
||||||
echo "Trying to checkout: $rev"
|
echo "Trying to checkout: $rev"
|
||||||
|
@ -18,6 +19,9 @@ if test -n "$rev"; then
|
||||||
git rev-parse --verify origin/"$rev" 2>/dev/null
|
git rev-parse --verify origin/"$rev" 2>/dev/null
|
||||||
)
|
)
|
||||||
git reset --hard $parsed_rev
|
git reset --hard $parsed_rev
|
||||||
|
git checkout -b __nixos_build__
|
||||||
|
else
|
||||||
|
git checkout -b __nixos_build__ origin/HEAD
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$leaveDotGit"; then
|
if test -z "$leaveDotGit"; then
|
||||||
|
|
Loading…
Reference in a new issue