Infer direct mode from existing pull requests - #366
Merged
Conversation
Move the direct-mode determination out of `__init__` into a new `_initialize_direct` method that runs after PR info has been prefetched, so it can consult the existing pull requests in the stack. Previously direct mode was resolved solely from the `--direct` / `--no-direct` flags, falling back to the presence of the `.github/ghstack_direct` marker file. Now, when the user hasn't passed an explicit flag and the marker doesn't force direct on, we inspect the base refs of the already-submitted PRs: a `gh/<user>/<n>/base` base ref indicates non-direct style, anything else indicates direct. If the stack mixes both styles we bail out with an error asking the user to pass `--direct` / `--no-direct` explicitly, rather than guessing. This lets an existing stack that was first submitted in direct mode keep being updated in direct mode without repeating the flag. Test plumbing changes to support this: - `direct` is now `Optional[bool]` throughout `test_prelude.py`; `None` means "infer". `check_global_github_invariants` only enforces the non-direct base-ref-reuse invariant when `direct is False`. - `gh_submit` gained a `**submit_kwargs` passthrough and a per-call `direct_opt` override so a test can submit one commit with an explicit mode and a later update with inference. - conftest now parametrizes on `direct` as before, but recognizes `*.unparametrized.py.test` scripts and runs them once with `direct=None`. Collection also matches on the `.py.test` filename suffix directly. New test `test/submit/infer_direct.unparametrized.py.test`: submit a commit with `direct_opt=True`, then amend and update without specifying a mode, exercising the inference path. [ghstack-poisoned]
Owner
Author
|
Stack from ghstack (oldest at bottom): |
This update reworks how the direct-mode inference is wired in. Rather than just renaming the `cat-file` result variable, `_initialize_direct` now keeps the original `direct_r`/`direct` computation and takes a `pr_info_cache` argument so it can consult existing pull requests. When `--direct`/`--no-direct` was not passed on the command line and the `.github/ghstack_direct` marker is absent, it now examines the base ref styles of the already-submitted PRs (matching against the `gh/<user>/<n>/base` pattern) to infer whether the stack was previously submitted in direct mode, instead of defaulting to non-direct. The call in `run()` is updated to pass the prefetched `pr_info_cache`. Also updates AGENTS.md to document the lint workflow via `uv run --frozen lintrunner --all-files` (and `lintrunner format` for fixes), replacing the older black/flake8 instructions. [ghstack-poisoned]
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.