feat: add land command for merging stacked PRs#28
Merged
Conversation
Add a new 'land' subcommand that intelligently merges a stack of PRs: - Finds the topmost PR where all PRs below it are approved - Updates that PR's base to the target branch (main/master) - Squash-merges that single PR (contains all commits from the stack) - Closes all PRs below it with a 'Landed via #N' comment Features: - --dry-run: Preview what would happen without making changes - --no-approval: Skip approval requirement check - --count N: Only land bottom N PRs in the stack - Draft PRs block landing of PRs above them This follows the spr/Graphite optimization pattern for efficient stack landing.
Add automatic repository detection from git remote URL, eliminating the need to pass -r flag or set GHSTACK_TARGET_REPOSITORY when running from inside a git repository. Changes: - Add parse_github_remote_url() to parse SSH/HTTPS URLs (including GitHub Enterprise) - Add detect_repo_from_remote() to extract owner/repo from git remote - Add resolve_repository() helper with fallback chain: -r flag -> env var -> auto-detect - Add --origin/-o flag to specify which remote to use (defaults to 'origin') - Update annotate, log, autorebase, and land commands to use auto-detection - Add unit tests for URL parsing
cc87179 to
9c25e3f
Compare
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.
Summary
Adds a new
landsubcommand that intelligently merges a stack of PRs using the spr/Graphite optimization pattern, plus automatic repository detection from git remotes.How it works
Usage
Features
Land Command
--dry-run: Preview what would happen without making changes--no-approval: Skip approval requirement check--count N: Only land bottom N PRs in the stackAuto-detect Repository (NEW)
owner/repofrom git remote URL-rflag →GHSTACK_TARGET_REPOSITORYenv var → auto-detect--origin/-oflag to specify which remote to use (defaults to "origin")Detected repository: owner/repo (from origin remote)annotate,log,autorebase,landChanges
src/land.rsmodule with landing logicsrc/api/land.rsmodule with GitHub API methods for merge/close/updatelandsubcommand to CLI inmain.rsparse_github_remote_url()anddetect_repo_from_remote()insrc/tree.rsresolve_repository()helper with fallback chain inmain.rs--originflag toannotate,log,autorebase, andlandcommandsserial_testdev dependency for API mock tests