Add entire trail merge subcommand#1462
Open
matthiaswenz wants to merge 1 commit into
Open
Conversation
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
Contributor
There was a problem hiding this comment.
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 mergecommand 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
https://entire.io/gh/entireio/cli/trails/604
Summary
Adds an
entire trail mergesubcommand that merges a trail's branch into its base, after first checking the trail is mergeable. A--dry-runflag reports mergeability without performing the merge.The Entire API already exposes the needed endpoints (
GET .../{number}/mergeabilityandPOST .../{number}/merge); this wires the CLI up to them.Behavior
--trail(number, id, or branch), or the current branch's trail when omitted.--dry-runstops after the check. It exits non-zero when the trail isn't mergeable, so it can gate CI.ok:truesignal (mirroringdeleteTrailByNumber) before reporting the merge commit SHA.Changes
api/trail_types.go—TrailMergeabilityResponse,TrailMergeResponse.trail_cmd.go—newTrailMergeCmd,runTrailMerge,fetchTrailMergeability,mergeTrailByNumber,printTrailMergeability,describeMergeBlockers. Extracts a sharedresolveTrailBySelectorhelper and refactorsrunTrailShowto use it (removing duplicate selector-resolution logic).trail_merge_cmd_test.go— tests for the API helpers (path/method, server-error surfacing,ok:falserejection, 422 gate-failure message),describeMergeBlockersacross 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--trailor 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-runstops after the check (non-zero exit when blocked, suitable for CI). Successful merges require the server’sok: truebefore reporting the merge commit SHA, matchingdeleteTrailByNumber.New API types
TrailMergeabilityResponseandTrailMergeResponsedecode those endpoints.resolveTrailBySelectoris extracted fromrunTrailShowfor shared lookup.trail_merge_cmd_test.gocovers HTTP helpers, blocker text, and summary output.Reviewed by Cursor Bugbot for commit 0b76faf. Configure here.