terminal user interface to jujutsu. Focused on speed and clarity
at re-based 52 lines 1.6 kB view raw
1#!/usr/bin/env bash 2set -euo pipefail 3 4# Regenerate the JSONL fixture used by `jj_tui/lib/render_jj_graph_tests.ml`. 5# 6# Usage: 7# ./scripts/update_render_jj_graph_test_data.sh [REVSET] [OUTFILE] 8# 9# Defaults: 10# REVSET = 'all()' 11# OUTFILE = 'test/jj_log.json' 12# 13# Notes: 14# - Output is JSONL (one JSON object per line). 15# - `wip` is a heuristic derived from the description's first line starting with "wip:". 16 17REVSET="" 18OUTFILE="${2:-test/jj_log.json}" 19 20echo "Updating $OUTFILE with revset: $REVSET" >&2 21 22TEMPLATE=$(cat <<'JJTEMPLATE' 23'{' 24 ++ '"commit_id":' ++ json(commit_id) 25 ++ ',"parents":[' ++ parents.map(|c| json(c.commit_id())).join(",") ++ ']' 26 ++ ',"change_id":' ++ json(change_id) 27 ++ ',"description":' ++ json(description) 28 ++ ',"author":{"name":' ++ json(author.name()) 29 ++ ',"email":' ++ json(author.email()) 30 ++ ',"timestamp":' ++ json(author.timestamp()) 31 ++ '}' 32 ++ ',"committer":{"name":' ++ json(committer.name()) 33 ++ ',"email":' ++ json(committer.email()) 34 ++ ',"timestamp":' ++ json(committer.timestamp()) 35 ++ '}' 36 ++ ',"working_copy":' ++ json(current_working_copy) 37 ++ ',"immutable":' ++ json(immutable) 38 ++ ',"wip":' ++ json(description.first_line().starts_with("wip:")) 39 ++ '} 40 ' 41JJTEMPLATE 42) 43 44 45mkdir -p "$(dirname "$OUTFILE")" 46# We want a stable "top-to-bottom" order like `jj log`, but without graph text. 47# Write to a temp file first so parse errors don't clobber the existing fixture. 48tmp_out="${OUTFILE}.tmp" 49jj log -T "$TEMPLATE" > "$tmp_out" 50mv "$tmp_out" "$OUTFILE" 51 52echo "Wrote $OUTFILE" >&2