Repository navigation
feat: add --base option to scope auto-scope to a git ref - #105
Merged
Merged
Conversation
--auto-scope only compared the working tree to HEAD, so a clean CI checkout selected nothing. With --base <ref>, changes are taken relative to the merge base of the ref and HEAD, including committed ones.
amannocci
force-pushed
the
feat/auto-scope-base-ref
branch
from
October 17, 2026 10:24
ae70070 to
1190a3b
Compare
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.
🧑💻What is the change being made?
Adds a
--base <ref>option toplan,apply,destroy,docsandmigrate, usable together with--auto-scope. Changes are then taken relative to the merge base of<ref>andHEAD(git merge-base) instead ofHEAD, so commits already made on the branch count, along with staged, unstaged and untracked changes. The shared-file mapping from #104 uses the same base.--basewithout--auto-scope, and an unknown or empty ref, are rejected with an explained error. The diff uses--no-renamesso that both the source and the destination of a moved file are in scope, and the ref is passed to git after--.❓ Why is the change being made?
--auto-scopecompared the working tree toHEAD. On a CI checkout the tree is clean, soterranova plan -Aselected no resource group and the job passed without planning anything. A configurable base lets CI runterranova plan -A --base origin/mainagainst the files a pull request changed.✅ How has this been tested?
Added integration tests in
tests/it/test_helpers.pyusing real git repositories: committed changes picked up through the base, uncommitted changes included, shared dependencies mapped through the base, a renamed file selecting both groups, invalid refs (unknown, empty, option-like) rejected, and an empty ref without--auto-scoperejected. Added e2e tests forplan -A --baseon a clean tree, and for--basewithout--auto-scopeonplanandapply. The full suite passes (495 tests), andruffandbasedpyrightare clean on the changed files. Commit boilerplate in the tests was merged into onecommit_allhelper.📚 How has this been documented?
Added a bullet to the "How to scope a run to what changed" section of the README describing
--base, including the need for full history on a CI checkout (fetch-depth: 0), plus aterranova plan -A --base origin/mainexample. The--baseoption has its own--helptext, and theauto_scope_resource_dirsdocstring was updated.🔗 Related Issues
Partially addresses #103 (the base ref case). This PR is stacked on #104, which fixes the shared-file case, so it targets that branch until #104 merges. The opt-in expansion to groups that import from a changed group is not part of this PR, so the issue stays open.