Author: chaoflow
Date: Wed Apr 27 03:00:47 2011
New Revision: 26984
URL: https://svn.nixos.org/websvn/nix/?rev=26984&sc=1

Log:
fetchgit builder rewrite to handle more cases

The old builder failed for:
- remote HEAD != master
- local repositories

Modified:
   nixpkgs/trunk/pkgs/build-support/fetchgit/builder.sh

Modified: nixpkgs/trunk/pkgs/build-support/fetchgit/builder.sh
==============================================================================
--- nixpkgs/trunk/pkgs/build-support/fetchgit/builder.sh        Wed Apr 27 
02:54:57 2011        (r26983)
+++ nixpkgs/trunk/pkgs/build-support/fetchgit/builder.sh        Wed Apr 27 
03:00:47 2011        (r26984)
@@ -2,19 +2,22 @@
 
 header "exporting $url (rev $rev) into $out"
 
-git clone "$url" $out
-if test -n "$rev"; then
-  cd $out
+git init $out
+cd $out
+git remote add origin "$url"
+git fetch origin
+git remote set-head origin -a
 
-  # Track all remote branches so that revisions like
-  # `t/foo@{2010-05-12}' are correctly resolved.  Failing to do that,
-  # Git bails out with an "invalid reference" error.
-  for branch in $(git branch -rl | grep -v ' origin/master$')
-  do
-    git branch --track "$(echo $branch | sed -es,origin/,,g)" "$branch"
-  done
+# If no revision was specified, the remote HEAD will be used
+git checkout -b __nixos_build__ origin/HEAD
 
-  git checkout "$rev" --
+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
_______________________________________________
nix-commits mailing list
[email protected]
http://mail.cs.uu.nl/mailman/listinfo/nix-commits

Reply via email to