Loading
feat(mr): add mr note publish to publish pending review comments
What does this MR do and why?
Adds glab mr note publish, which publishes all of the current user's pending review comments on a merge request — completing the review flow started with glab mr note create --draft (!3885 (merged), merged).
Behavior:
glab mr note publish [<id> | <branch>]lists the user's pending review comments (paginated withgitlab.ScanAndCollect,per_page=100), shows the count in a confirmation prompt, and publishes them via the draft-notes bulk publish endpoint.-m/--messageattaches a summary note;--internalrestricts it to project members with at least the Reporter role (requires--message).--reviewer-state requested_changes|reviewedsets the review state; neither records a formal approval.--yes/-yskips the confirmation prompt and is required when not running interactively (parity withglab mr note delete).- No pending comments →
no pending review comments on !<iid>error.
Dependencies
Built on gitlab-org/api/client-go!3057 (merged) (PublishAllDraftNotesWithOptions), merged and released in client-go v3.12.0; this MR bumps gitlab.com/gitlab-org/api/client-go/v3 v3.6.0 → v3.12.0 (the only go.sum delta — client-go's own go.mod is unchanged between the versions, so no transitive dependency moves).
Originally stacked on !3885 (merged)'s branch; retargeted to main and rebased after !3885 (merged) merged.
Verification
Exercised end-to-end against a local GDK instance (gdk.test:3000):
- Committed integration test
Test_MrNotePublish_Integration(taggedintegration): draft create → non-interactive--yesrejection → publish with summary +--reviewer-state reviewed→ drafts drained, notes present → re-publish errors withno pending review comments. Cleans up after itself. Re-run green against the released client-go v3.12.0. - Manual pagination smoke: 103 seeded drafts across two pages;
echo | glab mr note publish <iid>→--yes required when not running interactively;glab mr note publish <iid> -y -m "summary" --reviewer-state reviewed→✓ Published 103 pending review comments.; draft list drained; re-run errors. - The interactive TTY confirmation prompt (decline and accept) was additionally exercised end-to-end against GDK in a recorded terminal session.
Review notes
- The confirmation decline path is covered by
Test_cmdPublish_DeclinePrompt(PTY console harness, modeled onpackages/delete): pins the count-bearing prompt text, declines, assertsAborted.and that nothing is published (Times(0)). - The accepted list→publish TOCTOU (the endpoint cannot pin a note set) is mitigated by the count-bearing confirmation prompt.
Edited by Andrei Zubov