Skip to content

Add entire trail merge subcommand#1462

Open
matthiaswenz wants to merge 1 commit into
mainfrom
cli-trail-merge
Open

Add entire trail merge subcommand#1462
matthiaswenz wants to merge 1 commit into
mainfrom
cli-trail-merge

Conversation

@matthiaswenz

@matthiaswenz matthiaswenz commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

https://entire.io/gh/entireio/cli/trails/604

Summary

Adds an entire trail merge subcommand that merges a trail's branch into its base, after first checking the trail is mergeable. A --dry-run flag reports mergeability without performing the merge.

The Entire API already exposes the needed endpoints (GET .../{number}/mergeability and POST .../{number}/merge); this wires the CLI up to them.

Behavior

  • Resolves the trail from --trail (number, id, or branch), or the current branch's trail when omitted.
  • Always checks mergeability first and prints a readiness summary (approvals, CI checks, up-to-date with base).
  • Refuses to merge when the trail isn't mergeable, listing the blockers in the same order the server evaluates its gates.
  • --dry-run stops after the check. It exits non-zero when the trail isn't mergeable, so it can gate CI.
  • On a real run, performs the merge and verifies the server's ok:true signal (mirroring deleteTrailByNumber) before reporting the merge commit SHA.
$ entire trail merge --help
Merge a trail's branch into its base branch.
...
Flags:
      --dry-run        Only check whether the trail is mergeable; do not merge
      --trail string   Trail to merge (number, id, or branch; defaults to the current branch's trail)

Changes

  • api/trail_types.goTrailMergeabilityResponse, TrailMergeResponse.
  • trail_cmd.gonewTrailMergeCmd, runTrailMerge, fetchTrailMergeability, mergeTrailByNumber, printTrailMergeability, describeMergeBlockers. Extracts a shared resolveTrailBySelector helper and refactors runTrailShow to use it (removing duplicate selector-resolution logic).
  • trail_merge_cmd_test.go — tests for the API helpers (path/method, server-error surfacing, ok:false rejection, 422 gate-failure message), describeMergeBlockers across all gate states, and the summary output.

Testing

  • mise run check (fmt + lint + unit + integration + e2e canary) passes.

🤖 Generated with Claude Code


Note

Medium Risk
Merging changes remote git state via the server; the CLI gates on mergeability first and verifies ok:true, but mistaken merges in automation remain the main operational risk.

Overview
Adds entire trail merge, which merges a trail’s branch into its base via existing API routes (GET …/mergeability, POST …/merge). The command resolves the trail with --trail or the current branch, requires a trail number, always prints a readiness summary (approvals, CI, up-to-date), and refuses to merge with ordered blocker messages when not mergeable. --dry-run stops after the check (non-zero exit when blocked, suitable for CI). Successful merges require the server’s ok: true before reporting the merge commit SHA, matching deleteTrailByNumber.

New API types TrailMergeabilityResponse and TrailMergeResponse decode those endpoints. resolveTrailBySelector is extracted from runTrailShow for shared lookup. trail_merge_cmd_test.go covers HTTP helpers, blocker text, and summary output.

Reviewed by Cursor Bugbot for commit 0b76faf. Configure here.

Merge a trail's branch into its base, gated on mergeability. The trail
is resolved from --trail (number, id, or branch) or the current branch.

- Checks mergeability first via GET .../{number}/mergeability and prints
  a readiness summary (approvals, CI checks, up-to-date with base).
- Refuses to merge when not mergeable, listing the blockers in the same
  order the server evaluates its gates.
- --dry-run reports mergeability without merging; exits non-zero when not
  mergeable so it can gate CI.
- Performs the merge via POST .../{number}/merge and verifies ok:true
  before reporting the merge commit.

Extracts a shared resolveTrailBySelector helper and refactors
runTrailShow to use it.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Entire-Checkpoint: 423f73da96c6
Copilot AI review requested due to automatic review settings June 18, 2026 12:31
@matthiaswenz matthiaswenz requested a review from a team as a code owner June 18, 2026 12:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new entire trail merge subcommand that checks a trail’s mergeability (approvals, CI checks, and base-branch freshness) and, when eligible, triggers a server-side merge; supports --dry-run to report mergeability without performing the merge.

Changes:

  • Introduces entire trail merge command wiring and shared trail selector resolution (resolveTrailBySelector) in the trail command implementation.
  • Adds API response types for mergeability and merge endpoints.
  • Adds unit tests covering mergeability/merge API helpers and mergeability summary/blocker rendering.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
cmd/entire/cli/trail_cmd.go Adds trail merge command plus mergeability/merge helpers and factors selector resolution into resolveTrailBySelector.
cmd/entire/cli/api/trail_types.go Adds TrailMergeabilityResponse and TrailMergeResponse API types.
cmd/entire/cli/trail_merge_cmd_test.go Adds tests for merge API helpers, blocker ordering/text, and mergeability summary output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants