Skip to content

Commit a1b0c7a

Browse files
committed
Add 'land.style' option.
The option can be used to disable 'land' command entirely, or use the currently implemented 'bottom-only' style of landing. In future we might implement other styles, such as "one-by-one" and "rebase-and-land". stack-info: PR: #102, branch: ZolotukhinM/stack/1
1 parent 6958176 commit a1b0c7a

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,11 @@ Options:
361361
362362
Land the bottom-most PR in the current stack.
363363
364-
Takes no additional arguments beyond common ones.
364+
Options:
365+
366+
- `--land-style`: Style of landing PRs. Choices: `disable`, `bottom-only` (default: `bottom-only` or from config)
367+
- `bottom-only`: Land one PR at a time (bottom-most in the stack)
368+
- `disable`: Disable the land command entirely, requiring PRs to be merged through GitHub web interface
365369
366370
#### abandon
367371
@@ -397,6 +401,12 @@ stack-pr config repo.reviewer=user1,user2
397401
398402
# Set custom branch name template
399403
stack-pr config repo.branch_name_template=$USERNAME/stack
404+
405+
# Disable the land command (require GitHub web interface for merging)
406+
stack-pr config land.style=disable
407+
408+
# Use "bottom-only" landing style for stacks
409+
stack-pr config land.style=bottom-only
400410
```
401411
402412
The config command modifies the config file (`.stack-pr.cfg` by default, or the path specified by `STACKPR_CONFIG` environment variable). If the file doesn't exist, it will be created. If a setting already exists, it will be updated.
@@ -421,4 +431,6 @@ remote=origin
421431
target=main
422432
reviewer=GithubHandle1,GithubHandle2
423433
branch_name_template=$USERNAME/$BRANCH
434+
[land]
435+
style=bottom-only
424436
```

src/stack_pr/cli.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,16 @@
198198
199199
Make sure the branch exists or specify a different target with --target option.
200200
"""
201+
ERROR_LAND_DISABLED = """The 'land' command is disabled.
202+
203+
Please merge your PRs through the GitHub web interface instead.
204+
205+
To override this setting for a single command:
206+
stack-pr land --land-style=bottom-only
207+
208+
Or to re-enable it permanently:
209+
stack-pr config land.style=bottom-only
210+
"""
201211
UPDATE_STACK_TIP = """
202212
If you'd like to push your local changes first, you can use the following command to update the stack:
203213
$ stack-pr export -B {top_commit}~{stack_size} -H {top_commit}"""
@@ -881,6 +891,7 @@ class CommonArgs:
881891
hyperlinks: bool
882892
verbose: bool
883893
branch_name_template: str
894+
land_style: str
884895

885896
@classmethod
886897
def from_args(cls, args: argparse.Namespace) -> CommonArgs:
@@ -892,6 +903,7 @@ def from_args(cls, args: argparse.Namespace) -> CommonArgs:
892903
args.hyperlinks,
893904
args.verbose,
894905
args.branch_name_template,
906+
args.land_style,
895907
)
896908

897909

@@ -972,6 +984,7 @@ def deduce_base(args: CommonArgs) -> CommonArgs:
972984
args.hyperlinks,
973985
args.verbose,
974986
args.branch_name_template,
987+
args.land_style,
975988
)
976989

977990

@@ -1210,6 +1223,11 @@ def delete_remote_branches(
12101223
def command_land(args: CommonArgs) -> None:
12111224
log(h("LAND"), level=1)
12121225

1226+
# Check if land command is disabled
1227+
if args.land_style == "disable":
1228+
error(ERROR_LAND_DISABLED)
1229+
sys.exit(1)
1230+
12131231
current_branch = get_current_branch_name()
12141232

12151233
if should_update_local_base(
@@ -1518,6 +1536,12 @@ def create_argparser(
15181536
default=config.get("repo", "branch_name_template", fallback="$USERNAME/stack"),
15191537
help="A template for names of the branches stack-pr would use.",
15201538
)
1539+
common_parser.add_argument(
1540+
"--land-style",
1541+
default=config.get("land", "style", fallback="bottom-only"),
1542+
choices=["disable", "bottom-only"],
1543+
help="Style of landing PRs: 'bottom-only' lands one PR per invocation, 'disable' disables the land command.",
1544+
)
15211545

15221546
parser_submit = subparsers.add_parser(
15231547
"submit",

0 commit comments

Comments
 (0)