Latest review note

This commit is contained in:
2026-10-02 14:41:26 +03:00
parent 2e2960c159
commit e7adb3e88b
2 changed files with 39 additions and 1 deletions
+19
View File
@@ -57,12 +57,31 @@ cmd_write() {
fi
}
cmd_latest() {
local branch="${1:-$(git branch --show-current)}"
local blob obj note br rnd best="" best_round=-1
while read -r blob obj; do
note=$(git notes --ref="$NOTES_REF" show "$obj") || continue
br=$(sed -n 's/^branch: //p' <<<"$note")
[ "$br" = "$branch" ] || continue
rnd=$(sed -n 's/^round: //p' <<<"$note")
[[ "$rnd" =~ ^[0-9]+$ ]] || continue
if [ "$rnd" -gt "$best_round" ]; then
best_round=$rnd
best=$note
fi
done < <(git notes --ref="$NOTES_REF" list)
[ -n "$best" ] || die "no review notes for branch: $branch"
printf '%s\n' "$best"
}
main() {
local cmd="${1:-}"
if [ $# -gt 0 ]; then shift; fi
case "$cmd" in
show) cmd_show "$@" ;;
write) cmd_write "$@" ;;
latest) cmd_latest "$@" ;;
*) usage ;;
esac
}