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.
This commit is contained in:
David Grayson 2016-06-29 20:57:28 -07:00 committed by zimbatm
parent 77ea161f19
commit f56ab9e5e4

View File

@ -20,6 +20,7 @@ http_proxy=${http_proxy:-}
fullRev= fullRev=
humanReadableRev= humanReadableRev=
commitDate= commitDate=
commitDateStrict8601=
if test -n "$deepClone"; then if test -n "$deepClone"; then
deepClone=true deepClone=true
@ -287,9 +288,12 @@ _clone_user_rev() {
fi;; fi;;
esac esac
fullRev="$(cd "$dir" && (git rev-parse "$rev" 2> /dev/null || git rev-parse "refs/heads/$branchName") | tail -n1)" pushd "$dir"
humanReadableRev="$(cd "$dir" && (git describe "$fullRev" 2> /dev/null || git describe --tags "$fullRev" 2> /dev/null || echo -- none --))" fullRev=$( (git rev-parse "$rev" 2>/dev/null || git rev-parse "refs/heads/$branchName") | tail -n1)
commitDate="$(cd "$dir" && git show --no-patch --pretty=%ci "$fullRev")" 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 # Allow doing additional processing before .git removal
eval "$NIX_PREFETCH_GIT_CHECKOUT_HOOK" eval "$NIX_PREFETCH_GIT_CHECKOUT_HOOK"
@ -337,6 +341,7 @@ print_results() {
echo "{" echo "{"
echo " \"url\": \"$url\"," echo " \"url\": \"$url\","
echo " \"rev\": \"$fullRev\"," echo " \"rev\": \"$fullRev\","
echo " \"date\": \"$commitDateStrict8601\","
echo -n " \"$hashType\": \"$hash\"" echo -n " \"$hashType\": \"$hash\""
if test -n "$fetchSubmodules"; then if test -n "$fetchSubmodules"; then
echo "," echo ","