From f56ab9e5e4a31ead55efd9e1d9b55ddf70533908 Mon Sep 17 00:00:00 2001 From: David Grayson Date: Wed, 29 Jun 2016 20:57:28 -0700 Subject: [PATCH] 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. --- pkgs/build-support/fetchgit/nix-prefetch-git | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/fetchgit/nix-prefetch-git b/pkgs/build-support/fetchgit/nix-prefetch-git index 9b330d821f8..1a54f7351c5 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 ","