Skip to content

Commit 3d6cc59

Browse files
author
Laszlo Kindrat
committed
Change land.style config option semantics
So that the `disable` value makes the `land` command hidden. stack-info: PR: #105, branch: laszlokindrat/stack/2
1 parent 22cac7d commit 3d6cc59

File tree

2 files changed

+8
-34
lines changed

2 files changed

+8
-34
lines changed

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -361,11 +361,7 @@ Options:
361361
362362
Land the bottom-most PR in the current stack.
363363
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
364+
If the `land.style` config option has the `disable` value, this command is not available.
369365
370366
#### abandon
371367

src/stack_pr/cli.py

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -199,16 +199,6 @@
199199
200200
Make sure the branch exists or specify a different target with --target option.
201201
"""
202-
ERROR_LAND_DISABLED = """The 'land' command is disabled.
203-
204-
Please merge your PRs through the GitHub web interface instead.
205-
206-
To override this setting for a single command:
207-
stack-pr land --land-style=bottom-only
208-
209-
Or to re-enable it permanently:
210-
stack-pr config land.style=bottom-only
211-
"""
212202
UPDATE_STACK_TIP = """
213203
If you'd like to push your local changes first, you can use the following command to update the stack:
214204
$ stack-pr export -B {top_commit}~{stack_size} -H {top_commit}"""
@@ -892,7 +882,6 @@ class CommonArgs:
892882
hyperlinks: bool
893883
verbose: bool
894884
branch_name_template: str
895-
land_style: str
896885

897886
@classmethod
898887
def from_args(cls, args: argparse.Namespace) -> CommonArgs:
@@ -904,7 +893,6 @@ def from_args(cls, args: argparse.Namespace) -> CommonArgs:
904893
args.hyperlinks,
905894
args.verbose,
906895
args.branch_name_template,
907-
args.land_style,
908896
)
909897

910898

@@ -985,7 +973,6 @@ def deduce_base(args: CommonArgs) -> CommonArgs:
985973
args.hyperlinks,
986974
args.verbose,
987975
args.branch_name_template,
988-
args.land_style,
989976
)
990977

991978

@@ -1224,11 +1211,6 @@ def delete_remote_branches(
12241211
def command_land(args: CommonArgs) -> None:
12251212
log(h("LAND"), level=1)
12261213

1227-
# Check if land command is disabled
1228-
if args.land_style == "disable":
1229-
error(ERROR_LAND_DISABLED)
1230-
sys.exit(1)
1231-
12321214
current_branch = get_current_branch_name()
12331215

12341216
if should_update_local_base(
@@ -1537,12 +1519,6 @@ def create_argparser(
15371519
default=config.get("repo", "branch_name_template", fallback="$USERNAME/stack"),
15381520
help="A template for names of the branches stack-pr would use.",
15391521
)
1540-
common_parser.add_argument(
1541-
"--land-style",
1542-
default=config.get("land", "style", fallback="bottom-only"),
1543-
choices=["disable", "bottom-only"],
1544-
help="Style of landing PRs: 'bottom-only' lands one PR per invocation, 'disable' disables the land command.",
1545-
)
15461522

15471523
parser_submit = subparsers.add_parser(
15481524
"submit",
@@ -1585,11 +1561,13 @@ def create_argparser(
15851561
help="Stash all uncommited changes before submitting the PR",
15861562
)
15871563

1588-
subparsers.add_parser(
1589-
"land",
1590-
help="Land the current stack",
1591-
parents=[common_parser],
1592-
)
1564+
land_style = config.get("land", "style", fallback="bottom-only")
1565+
if land_style == "bottom-only":
1566+
subparsers.add_parser(
1567+
"land",
1568+
help="Land the bottom-most PR in the current stack",
1569+
parents=[common_parser],
1570+
)
15931571
subparsers.add_parser(
15941572
"abandon",
15951573
help="Abandon the current stack",

0 commit comments

Comments
 (0)