Skip to content

Commit 76c06b2

Browse files
authored
feat: add land command for merging stacked PRs (#28)
1 parent f503c87 commit 76c06b2

10 files changed

Lines changed: 1277 additions & 44 deletions

File tree

Cargo.lock

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ chrono = { version = "0.4", features = ["serde"] }
3030
[dev-dependencies]
3131
insta = "1.39"
3232
mockito = "1.4"
33+
serial_test = "3.1"
3334
tokio-test = "0.4"

README.md

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ With this graph built up, the tool can:
2323
- Add a markdown table to the PR description (idempotently) of each PR in the stack describing _all_ PRs in the stack.
2424
- Log a simple list of all PRs in the stack (+ dependencies) to stdout.
2525
- Automatically update the stack + push after making local changes.
26+
- **Land an entire stack** by squash-merging the topmost approved PR and closing the rest.
2627

2728
---
2829

@@ -66,7 +67,8 @@ cargo install --force --path .
6667
# Set the environment variable for the Github API token
6768
$ export GHSTACK_OAUTH_TOKEN='<personal access token>'
6869

69-
# Set the environment variable for the repository owner/name
70+
# Optional: The repository is auto-detected from your git remote.
71+
# You can override it with an environment variable or the -r flag:
7072
$ export GHSTACK_TARGET_REPOSITORY='<github repository name>'
7173

7274
# You can also set these in a `.gh-stack.env` file in the project root.
@@ -84,17 +86,18 @@ FLAGS:
8486
SUBCOMMANDS:
8587
annotate Annotate the descriptions of all PRs in a stack with metadata about all PRs in the stack
8688
autorebase Rebuild a stack based on changes to local branches and mirror these changes up to the remote
89+
land Land a stack by squash-merging the topmost approved PR and closing the rest
8790
log Print a list of all pull requests in a stack to STDOUT
8891
rebase Print a bash script to STDOUT that can rebase/update the stack (with a little help)
8992

90-
# Print a description of the stack to stdout. for a specific repository.
93+
# Print a description of the stack to stdout (auto-detects repository from git remote)
9194
$ gh-stack log 'stack-identifier'
9295

93-
# # Idempotently add a markdown table summarizing the stack
94-
# to the description of each PR in the stack for a specific repository.
96+
# Idempotently add a markdown table summarizing the stack
97+
# to the description of each PR in the stack
9598
$ gh-stack annotate 'stack-identifier'
9699

97-
# Same as above, but for the specified repository.
100+
# Override auto-detected repository with -r flag
98101
$ gh-stack annotate 'stack-identifier' -r '<some/repo>'
99102

100103
# Same as above, but with a custom title prefix.
@@ -116,6 +119,18 @@ $ gh-stack autorebase 'stack-identifier' -C /path/to/repo
116119
# Same as above, but skips confirmation step.
117120
$ gh-stack autorebase 'stack-identifier' -C /path/to/repo --ci
118121

122+
# Land the entire stack (squash-merges topmost approved PR, closes the rest)
123+
$ gh-stack land 'stack-identifier'
124+
125+
# Preview what would happen without making changes
126+
$ gh-stack land 'stack-identifier' --dry-run
127+
128+
# Skip approval requirement check
129+
$ gh-stack land 'stack-identifier' --no-approval
130+
131+
# Only land the bottom N PRs in the stack
132+
$ gh-stack land 'stack-identifier' --count 2
133+
119134
# Emit a bash script that can update a stack in the case of conflicts.
120135
# WARNING: This script could potentially cause destructive behavior.
121136
$ gh-stack rebase 'stack-identifier'

0 commit comments

Comments
 (0)