fix(mr): report accurate merge state instead of always "Merged!"

What does this MR do?

glab mr merge printed ✓ Merged! on any successful AcceptMergeRequest response, even when the merge request stayed open — while auto-merge was armed awaiting a pipeline, or when a requirement such as pending approvals or unresolved discussions meant the merge had not completed.

Fix

Report success only on the one unambiguous signal, and surface the API's merge status otherwise:

  1. Mergedmr.State == "merged"✓ Merged!.
  2. Auto-merge armed — an open MR with MergeWhenPipelineSucceeds✓ Auto-merge enabled.
  3. Any other open response! Merge status: <detailed_merge_status>, surfacing the API value verbatim (e.g. mergeable, discussions_not_resolved) rather than guessing whether the merge happened.

This keys auto-merge detection on the API arm signal rather than a transient non-merged state. It intentionally avoids maintaining a hand-written list of "blocker" statuses, since GitLab extends the detailed_merge_status enum over time and any omission would silently reprint the false Merged!.

Testing

  • go test ./internal/commands/mr/merge/... passes. Cases cover: auto-merge armed on a successful pipeline, a running-pipeline armed response, open responses after an immediate merge (default and --auto-merge=false), a successful pipeline that reports merged, an immediate conflict error, and an open, unarmed response carrying a blocker status.
  • golangci-lint run ./internal/commands/mr/merge/... → 0 issues.

Supersedes !3475 (closed), moved to the gitlab-community fork so CI runs on trusted runners. Rebased onto current main; commit is DCO signed-off.

Closes #8485 (closed)

🤖 Generated with Claude Code

Edited by Zander Otavka

Merge request reports

Loading
Loading