Skip to content

Commit a53b4fe

Browse files
authored
Check .github/ghstack_direct to decide if using direct by default (#258)
1 parent 600e9c8 commit a53b4fe

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

.github/ghstack_direct

Whitespace-only changes.

ghstack/submit.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,18 @@ def __post_init__(self) -> None:
406406
default_branch = repo["default_branch"]
407407

408408
object.__setattr__(self, "base", default_branch)
409-
object.__setattr__(self, "direct", bool(self.direct_opt))
409+
410+
# Check if direct should be used, if the user didn't explicitly
411+
# specify an option
412+
direct = self.direct_opt
413+
if direct is None:
414+
direct_r = self.sh.git(
415+
"cat-file", "-e", "HEAD:.github/ghstack_direct", exitcode=True
416+
)
417+
assert isinstance(direct_r, bool)
418+
direct = direct_r
419+
420+
object.__setattr__(self, "direct", direct)
410421

411422
# ~~~~~~~~~~~~~~~~~~~~~~~~
412423
# The main algorithm
@@ -667,7 +678,6 @@ def prepare_updates(
667678
commits_to_submit: List[ghstack.git.CommitHeader],
668679
commits_to_rebase: List[ghstack.git.CommitHeader],
669680
) -> Tuple[Dict[GitCommitHash, DiffMeta], Dict[GitCommitHash, GitCommitHash]]:
670-
671681
# Prepare diffs in reverse topological order.
672682
# (Reverse here is important because we must have processed parents
673683
# first.)

0 commit comments

Comments
 (0)