Latest review note
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user