about summary refs log tree commit diff
path: root/pkgs/build-support
diff options
context:
space:
mode:
authorDavid Grayson <davidegrayson@gmail.com>2016-06-29 20:57:28 -0700
committerzimbatm <zimbatm@zimbatm.com>2016-07-03 11:19:13 +0100
commitf56ab9e5e4a31ead55efd9e1d9b55ddf70533908 (patch)
tree3dd901bb25d7922612c67e3e1908d19cf2f2afff /pkgs/build-support
parent77ea161f190d6fa97a0f0eb6a795979a5f132f8d (diff)
downloadnixlib-f56ab9e5e4a31ead55efd9e1d9b55ddf70533908.tar
nixlib-f56ab9e5e4a31ead55efd9e1d9b55ddf70533908.tar.gz
nixlib-f56ab9e5e4a31ead55efd9e1d9b55ddf70533908.tar.bz2
nixlib-f56ab9e5e4a31ead55efd9e1d9b55ddf70533908.tar.lz
nixlib-f56ab9e5e4a31ead55efd9e1d9b55ddf70533908.tar.xz
nixlib-f56ab9e5e4a31ead55efd9e1d9b55ddf70533908.tar.zst
nixlib-f56ab9e5e4a31ead55efd9e1d9b55ddf70533908.zip
nix-prefetch-git: Include the date in the machine-readable output on
stdout, in strict ISO 8601 format.

This will be helpful for automatically updating fetchgit expressions
and the dates in version numbers associated with them.
Diffstat (limited to 'pkgs/build-support')
-rwxr-xr-xpkgs/build-support/fetchgit/nix-prefetch-git11
1 files changed, 8 insertions, 3 deletions
diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git
index 9b330d821f85..1a54f7351c5a 100755
--- a/pkgs/build-support/fetchgit/nix-prefetch-git
+++ b/pkgs/build-support/fetchgit/nix-prefetch-git
@@ -20,6 +20,7 @@ http_proxy=${http_proxy:-}
 fullRev=
 humanReadableRev=
 commitDate=
+commitDateStrict8601=
 
 if test -n "$deepClone"; then
     deepClone=true
@@ -287,9 +288,12 @@ _clone_user_rev() {
             fi;;
     esac
 
-    fullRev="$(cd "$dir" && (git rev-parse "$rev" 2> /dev/null || git rev-parse "refs/heads/$branchName") | tail -n1)"
-    humanReadableRev="$(cd "$dir" && (git describe "$fullRev" 2> /dev/null || git describe --tags "$fullRev" 2> /dev/null || echo -- none --))"
-    commitDate="$(cd "$dir" && git show --no-patch --pretty=%ci "$fullRev")"
+    pushd "$dir"
+    fullRev=$( (git rev-parse "$rev" 2>/dev/null || git rev-parse "refs/heads/$branchName") | tail -n1)
+    humanReadableRev=$(git describe "$fullRev" 2> /dev/null || git describe --tags "$fullRev" 2> /dev/null || echo -- none --)
+    commitDate=$(git show --no-patch --pretty=%ci "$fullRev")
+    commitDateStrict8601=$(git show --no-patch --pretty=%cI "$fullRev")
+    popd
 
     # Allow doing additional processing before .git removal
     eval "$NIX_PREFETCH_GIT_CHECKOUT_HOOK"
@@ -337,6 +341,7 @@ print_results() {
         echo "{"
         echo "  \"url\": \"$url\","
         echo "  \"rev\": \"$fullRev\","
+        echo "  \"date\": \"$commitDateStrict8601\","
         echo -n "  \"$hashType\": \"$hash\""
         if test -n "$fetchSubmodules"; then
             echo ","