diff --git a/scripts/review-note b/scripts/review-note index 3e2dafc..2173272 100755 --- a/scripts/review-note +++ b/scripts/review-note @@ -75,6 +75,11 @@ cmd_latest() { printf '%s\n' "$best" } +cmd_push() { + git rev-parse -q --verify "$NOTES_REF" >/dev/null || die "no review notes to push" + git push "$REMOTE" "$NOTES_REF" +} + main() { local cmd="${1:-}" if [ $# -gt 0 ]; then shift; fi @@ -82,6 +87,7 @@ main() { show) cmd_show "$@" ;; write) cmd_write "$@" ;; latest) cmd_latest "$@" ;; + push) cmd_push "$@" ;; *) usage ;; esac } diff --git a/scripts/review-note-test b/scripts/review-note-test index 4749c01..ee7369b 100755 --- a/scripts/review-note-test +++ b/scripts/review-note-test @@ -8,6 +8,7 @@ fail() { echo "FAIL: $*" >&2; exit 1; } tmp=$(mktemp -d) trap 'rm -rf "$tmp"' EXIT +git init -q --bare "$tmp/remote.git" git init -q -b main "$tmp/repo" cd "$tmp/repo" git config user.email test@example.com @@ -68,4 +69,13 @@ sed -e 's/^round: 1/round: 2/' -e "s/^previous: none/previous: $PREV/" "$tmp/not if "$rn" latest nosuch >/dev/null 2>&1; then fail "latest should exit 1 for an unknown branch"; fi -echo "ok: show/write/latest" +# push publishes notes to origin; a fresh clone picks them up +git remote add origin "$tmp/remote.git" +git push -q origin main +"$rn" push +git clone -q "$tmp/remote.git" "$tmp/clone" +cd "$tmp/clone" +git fetch -q origin "refs/notes/review:refs/notes/review" +"$rn" latest main | grep -q '^round: 2$' || fail "clone should see the round 2 note" + +echo "ok: show/write/latest/push"