Skip to content

Commit ce1a739

Browse files
Hide hints about land option when it's disabled (#110)
1 parent 00bc8e6 commit ce1a739

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/stack_pr/cli.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -903,9 +903,10 @@ class CommonArgs:
903903
verbose: bool
904904
branch_name_template: str
905905
show_tips: bool
906+
land_disabled: bool
906907

907908
@classmethod
908-
def from_args(cls, args: argparse.Namespace) -> CommonArgs:
909+
def from_args(cls, args: argparse.Namespace, *, land_disabled: bool) -> CommonArgs:
909910
return cls(
910911
args.base,
911912
args.head,
@@ -915,6 +916,7 @@ def from_args(cls, args: argparse.Namespace) -> CommonArgs:
915916
args.verbose,
916917
args.branch_name_template,
917918
args.show_tips,
919+
land_disabled,
918920
)
919921

920922

@@ -996,6 +998,7 @@ def deduce_base(args: CommonArgs) -> CommonArgs:
996998
args.verbose,
997999
args.branch_name_template,
9981000
args.show_tips,
1001+
args.land_disabled,
9991002
)
10001003

10011004

@@ -1009,7 +1012,8 @@ def print_tips_after_export(st: list[StackEntry], args: CommonArgs) -> None:
10091012
top_commit = get_current_branch_name()
10101013

10111014
log(b("\nOnce the stack is reviewed, it is ready to land!"), level=1)
1012-
log(LAND_STACK_TIP.format(**locals()))
1015+
if not args.land_disabled:
1016+
log(LAND_STACK_TIP.format(**locals()))
10131017

10141018

10151019
# ===----------------------------------------------------------------------=== #
@@ -1409,7 +1413,8 @@ def print_tips_after_view(st: list[StackEntry], args: CommonArgs) -> None:
14091413
if ready_to_land:
14101414
log(b("\nThis stack is ready to land!"))
14111415
log(UPDATE_STACK_TIP.format(**locals()))
1412-
log(LAND_STACK_TIP.format(**locals()))
1416+
if not args.land_disabled:
1417+
log(LAND_STACK_TIP.format(**locals()))
14131418
return
14141419

14151420
# Stack is not ready to land, suggest exporting it first
@@ -1651,7 +1656,12 @@ def main() -> None: # noqa: PLR0912
16511656

16521657
# Make sure "$ID" is present in the branch name template and append it if not
16531658
args.branch_name_template = fix_branch_name_template(args.branch_name_template)
1654-
common_args = CommonArgs.from_args(args)
1659+
common_args = CommonArgs.from_args(
1660+
args,
1661+
land_disabled=(
1662+
config.get("land", "style", fallback="bottom-only") == "disable"
1663+
),
1664+
)
16551665

16561666
if common_args.verbose:
16571667
logger.setLevel(logging.DEBUG)

0 commit comments

Comments
 (0)