nix-prefetch-pijul: show date

This commit is contained in:
·𐑑𐑴𐑕𐑑𐑩𐑤
2025-11-25 23:41:49 +07:00
parent 66a5440b03
commit bc3f1fd85c
@@ -6,6 +6,7 @@ remote=
channel="main"
change=
state=
date=
exp_hash=
usage() {
@@ -100,11 +101,15 @@ if [ -z "$final_path" ]; then
cd "$tmp_clone"
pijul clone $clone_args "$remote" "$name"
latest_log="$(pijul log --repository "$tmp_clone/$name" --limit 1)"
# State is a stable reference is a stable reference for the patchset that
# doesn't depend on patch order. As a result, it will always be included.
if [ -z "$state" ]; then
state="$(pijul log --repository "$tmp_clone/$name" --state --limit 1 | awk '/^State:/ {printf $2}')"
state="$(printf "%s" "$latest_log" | awk '/^State:/ {printf $2}')"
fi
date="$(printf "%s" "$latest_log" | awk '/^Date:/ { sub(/^Date:[[:space:]]*/, "", $0); printf $0 }')"
date="$(date -u -d "$date" "+%Y-%m-%dT%H:%M:%SZ")"
rm -rf "$tmp_clone/$name/.pijul"
hash="$(nix-hash --type "$hash_algo" "$hash_format" "$tmp_clone/$name")"
@@ -132,6 +137,7 @@ if [ -n "$change" ]; then cat <<EOF
EOF
fi; cat <<EOF
"state": $(json_escape "$state"),
"date": $(json_escape "$date"),
"path": "$final_path",
$(json_escape "$hash_algo"): $(json_escape "$hash"),
"hash": "$(nix-hash --to-sri --type "$hash_algo" "$hash")"