Skip to content

Commit 4fd94eb

Browse files
Scope provenance dirtiness to build context
1 parent f42f436 commit 4fd94eb

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

src/agentex/lib/utils/build_provenance.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,10 @@ def capture_build_provenance(
171171
except ValueError:
172172
subpath = None
173173

174-
# `git status --porcelain` is empty (→ _git returns None) for a clean tree.
175-
dirty = _git(repo_root_path, "status", "--porcelain") is not None
174+
status_args = ("status", "--porcelain")
175+
if subpath is not None:
176+
status_args += ("--", subpath)
177+
dirty = _git(repo_root_path, *status_args) is not None
176178

177179
return BuildProvenance(
178180
repo=remote,

tests/lib/test_build_provenance.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,3 +243,15 @@ def test_capture_monorepo_subpath(tmp_path: Path) -> None:
243243
prov = capture_build_provenance(repo, repo / "agents" / "foo")
244244

245245
assert prov.subpath == "agents/foo"
246+
247+
248+
def test_capture_monorepo_ignores_changes_outside_context(tmp_path: Path) -> None:
249+
repo = _init_repo(tmp_path / "repo")
250+
_write(repo, "agents/foo/main.py", "print(1)")
251+
_write(repo, "agents/bar/main.py", "print(2)")
252+
_commit_all(repo)
253+
_write(repo, "agents/bar/scratch.py", "debug = True")
254+
255+
prov = capture_build_provenance(repo, repo / "agents" / "foo")
256+
257+
assert prov.dirty is False

0 commit comments

Comments
 (0)