Bound note header parsing

This commit is contained in:
2026-10-02 15:13:04 +03:00
parent 773f3b550f
commit 0e5d76901d
2 changed files with 3 additions and 2 deletions
+2 -2
View File
@@ -62,9 +62,9 @@ cmd_latest() {
local blob obj note br rnd best="" best_round=-1 local blob obj note br rnd best="" best_round=-1
while read -r blob obj; do while read -r blob obj; do
note=$(git notes --ref="$NOTES_REF" show "$obj") || continue note=$(git notes --ref="$NOTES_REF" show "$obj") || continue
br=$(sed -n 's/^branch: //p' <<<"$note") br=$(sed -n '/^$/q; s/^branch: //p' <<<"$note")
[ "$br" = "$branch" ] || continue [ "$br" = "$branch" ] || continue
rnd=$(sed -n 's/^round: //p' <<<"$note") rnd=$(sed -n '/^$/q; s/^round: //p' <<<"$note")
[[ "$rnd" =~ ^[0-9]+$ ]] || continue [[ "$rnd" =~ ^[0-9]+$ ]] || continue
if [ "$rnd" -gt "$best_round" ]; then if [ "$rnd" -gt "$best_round" ]; then
best_round=$rnd best_round=$rnd
+1
View File
@@ -49,6 +49,7 @@ if "$rn" write "$note" >/dev/null 2>&1; then fail "write should refuse an existi
sed 's/^verdict: request-changes/verdict: approve/' "$note" > "$tmp/note1b" sed 's/^verdict: request-changes/verdict: approve/' "$note" > "$tmp/note1b"
"$rn" write "$tmp/note1b" --force "$rn" write "$tmp/note1b" --force
"$rn" show | grep -q '^verdict: approve$' || fail "show should print the replaced note" "$rn" show | grep -q '^verdict: approve$' || fail "show should print the replaced note"
"$rn" show | diff -u "$tmp/note1b" - || fail "show should print the note verbatim"
# latest finds the note by branch, even from a newer unreviewed tip # latest finds the note by branch, even from a newer unreviewed tip
echo three > c.txt && git add c.txt && git commit -qm three echo three > c.txt && git add c.txt && git commit -qm three