Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions server/local_git.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ async def run_git(cwd: str, args: list[str]) -> dict[str, Any]:
kwargs["creationflags"] = CREATE_NO_WINDOW
# Git quotes non-ASCII pathnames by default. Machine consumers must see
# repository paths, not display-oriented C-style escape text.
# Paths passed after "--" are repository paths taken from Git's own
# output, never patterns: a name such as "[id].tsx" must not glob-match
# "i.tsx", and a leading ":" must not be read as pathspec magic.
proc = await asyncio.create_subprocess_exec(
"git",
"-c",
"core.quotepath=false",
"--literal-pathspecs",
*args,
**kwargs,
)
Expand Down
43 changes: 43 additions & 0 deletions tests/test_work_artifact_registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,49 @@ async def run() -> None:
asyncio.run(run())


def test_attempt_patch_reads_changed_paths_literally_not_as_globs() -> None:
async def run() -> None:
with tempfile.TemporaryDirectory(prefix="work_artifact_literal_paths_") as temp:
root = Path(temp) / "project"
root.mkdir()
_git(root, "init")
_git(root, "config", "user.email", "amadeus-test@example.invalid")
_git(root, "config", "user.name", "Amadeus Test")
route = root / "[id].tsx"
route.write_text("route\n", encoding="utf-8")
(root / "i.tsx").write_text("clean\n", encoding="utf-8")
_git(root, "add", ".")
_git(root, "commit", "-m", "baseline")

# As a glob, "[id].tsx" also matches this pre-existing user edit.
(root / "i.tsx").write_text("dirty before run\n", encoding="utf-8")
store = WorkLedgerStore(Path(temp) / "ledger.sqlite3")
project = store.create_or_get_project(root)
item = store.create_work_item(project.project_id, title="Edit route")
attempt = store.create_attempt(item.work_item_id, provider="codex", task="Edit route")
registry = WorkArtifactRegistry(store)
await registry.capture_baseline(attempt, item)
route.write_text("route changed\n", encoding="utf-8")

current_attempt = store.get_attempt(attempt.attempt_id)
assert current_attempt is not None
delta = await registry.finalize_attempt(current_attempt, item)
store.close()

assert delta["changed_files"] == ["[id].tsx"]
assert delta["excluded_baseline_paths"] == ["i.tsx"]
parsed = parse_unified_diff(
delta["patch"],
changed_files=delta["changed_files"],
untracked=delta["untracked"],
)
assert [(entry["path"], entry["additions"], entry["deletions"]) for entry in parsed["files"]] == [
("[id].tsx", 1, 1),
]

asyncio.run(run())


def test_non_ascii_entry_revision_is_registered_as_the_real_path() -> None:
async def run() -> None:
with tempfile.TemporaryDirectory(prefix="work_artifact_unicode_") as temp:
Expand Down
Loading