diff options
author | Florian Friesdorf <flo@chaoflow.net> | 2011-04-27 03:00:47 +0000 |
---|---|---|
committer | Florian Friesdorf <flo@chaoflow.net> | 2011-04-27 03:00:47 +0000 |
commit | a8c3649dd415f453736283cc9630f6557935ac34 (patch) | |
tree | 19dc3f48de527669fb482bced6515a8e97d921b4 /pkgs/build-support | |
parent | ead24cacdfc2914cfe1784f317e67fc531f831d9 (diff) | |
download | nixpkgs-a8c3649dd415f453736283cc9630f6557935ac34.tar nixpkgs-a8c3649dd415f453736283cc9630f6557935ac34.tar.gz nixpkgs-a8c3649dd415f453736283cc9630f6557935ac34.tar.bz2 nixpkgs-a8c3649dd415f453736283cc9630f6557935ac34.tar.lz nixpkgs-a8c3649dd415f453736283cc9630f6557935ac34.tar.xz nixpkgs-a8c3649dd415f453736283cc9630f6557935ac34.tar.zst nixpkgs-a8c3649dd415f453736283cc9630f6557935ac34.zip |
fetchgit builder rewrite to handle more cases
The old builder failed for: - remote HEAD != master - local repositories svn path=/nixpkgs/trunk/; revision=26984
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/fetchgit/builder.sh | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/pkgs/build-support/fetchgit/builder.sh b/pkgs/build-support/fetchgit/builder.sh index 794b690341e..7e363911bac 100644 --- a/pkgs/build-support/fetchgit/builder.sh +++ b/pkgs/build-support/fetchgit/builder.sh @@ -2,19 +2,22 @@ source $stdenv/setup 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 |