Skip to content

Commit 0ed013b

Browse files
authored
Prepare for direct inference by renaming the flag in cli (#256)
1 parent 4a946a3 commit 0ed013b

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

ghstack/cli.py

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ def cli_context(
5757
@click.option("--force", is_flag=True, hidden=True)
5858
@click.option("--no-skip", is_flag=True, hidden=True)
5959
@click.option("--draft", is_flag=True, hidden=True)
60-
@click.option("--direct", is_flag=True, hidden=True)
60+
@click.option(
61+
"--direct/--no-direct", "direct_opt", is_flag=True, hidden=True, default=None
62+
)
6163
@click.option("--base", "-B", default=None, hidden=True)
6264
@click.option("--stack/--no-stack", "-s/-S", is_flag=True, default=True, hidden=True)
6365
def main(
@@ -67,7 +69,7 @@ def main(
6769
update_fields: bool,
6870
short: bool,
6971
force: bool,
70-
direct: bool,
72+
direct_opt: Optional[bool],
7173
no_skip: bool,
7274
draft: bool,
7375
base: Optional[str],
@@ -89,7 +91,7 @@ def main(
8991
draft=draft,
9092
base=base,
9193
stack=stack,
92-
direct=direct,
94+
direct_opt=direct_opt,
9395
)
9496

9597

@@ -226,7 +228,11 @@ def status(pull_request: str) -> None:
226228
"listed in the command line.",
227229
)
228230
@click.option(
229-
"--direct", is_flag=True, help="Create stack that directly merges into master"
231+
"--direct/--no-direct",
232+
"direct_opt",
233+
default=None,
234+
is_flag=True,
235+
help="Create stack that directly merges into master",
230236
)
231237
@click.argument(
232238
"revs",
@@ -240,7 +246,7 @@ def submit(
240246
force: bool,
241247
no_skip: bool,
242248
draft: bool,
243-
direct: bool,
249+
direct_opt: Optional[bool],
244250
base: Optional[str],
245251
revs: Tuple[str, ...],
246252
stack: bool,
@@ -264,7 +270,7 @@ def submit(
264270
base_opt=base,
265271
revs=revs,
266272
stack=stack,
267-
direct=direct,
273+
direct_opt=direct_opt,
268274
)
269275

270276

ghstack/submit.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ class Submitter:
341341

342342
# Instead of merging into base branch, merge directly into the appropriate
343343
# main or head branch. Change merge targets appropriately as PRs get
344-
# merged
345-
direct: bool = False
344+
# merged. If None, infer whether or not the PR should be direct or not.
345+
direct_opt: Optional[bool] = None
346346

347347
# ~~~~~~~~~~~~~~~~~~~~~~~~
348348
# Computed in post init
@@ -356,6 +356,8 @@ class Submitter:
356356

357357
base: str = dataclasses.field(init=False)
358358

359+
direct: bool = dataclasses.field(init=False)
360+
359361
# ~~~~~~~~~~~~~~~~~~~~~~~~
360362
# Mutable state; TODO: remove me
361363

@@ -404,6 +406,7 @@ def __post_init__(self) -> None:
404406
default_branch = repo["default_branch"]
405407

406408
object.__setattr__(self, "base", default_branch)
409+
object.__setattr__(self, "direct", bool(self.direct_opt))
407410

408411
# ~~~~~~~~~~~~~~~~~~~~~~~~
409412
# The main algorithm

ghstack/test_prelude.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def gh_submit(
201201
repo_owner_opt="pytorch",
202202
repo_name_opt="pytorch",
203203
short=short,
204-
direct=self.direct,
204+
direct_opt=self.direct,
205205
no_skip=no_skip,
206206
github_url="github.com",
207207
remote_name="origin",

0 commit comments

Comments
 (0)