summaryrefslogtreecommitdiffstats
path: root/bin/fetchgit
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2015-06-28 15:04:45 +0200
committertv <tv@krebsco.de>2015-06-28 15:06:12 +0200
commit530d385ac9b8ca19f8f78ff6da098d668ac8ed9a (patch)
tree3b84c415cbdc02394bed0b8ee698ea078842168a /bin/fetchgit
parentd503dbd4ff1f225f4685831e2354b36d96e70996 (diff)
fetchgit: allow using dirty local work trees
Diffstat (limited to 'bin/fetchgit')
-rwxr-xr-xbin/fetchgit26
1 files changed, 20 insertions, 6 deletions
diff --git a/bin/fetchgit b/bin/fetchgit
index 7862989..ba5b40b 100755
--- a/bin/fetchgit
+++ b/bin/fetchgit
@@ -1,14 +1,27 @@
#! /bin/sh
#
-# usage: fetchgit git_rev git_url out_link
+# usage: fetchgit repo_name out_link
#
-# Clone the specified Git repository and make it available as out_link.
+# Make the specified repository available as out_link.
#
set -euf
-git_rev=$1
-git_url=$2
-out_link=$3
+repo_name=$1
+out_link=$2
+
+if test "$repo_name" != nixpkgs; then
+ echo "fetchgit: cannot fetch $repo_name, yet" >&2
+ exit -1
+fi
+
+git_rev=$(nixos-query nixpkgs.rev)
+git_url=$(nixos-query nixpkgs.url)
+dirty=$(nixos-query nixpkgs.dirty)
+
+case $dirty in true)
+ ln -snf "$git_url" "$out_link"
+ exit
+esac
# Put all bases in the same place as out_link.
# Notice how out_link must not clash with cache_dir and work_dir.
@@ -39,7 +52,8 @@ is_up_to_date() {
test "$(work_git rev-parse --verify HEAD)" = "$git_rev"
}
-# Notice how the remote name "origin" has been chosen arbitrarily.
+# Notice how the remote name "origin" has been chosen arbitrarily, but must be
+# kept in sync with the default value of nixpkgs.rev.
if ! is_up_to_date; then
if ! test -d "$cache_dir"; then
mkdir -p "$cache_dir"