Repository navigation
Keep PR content from hiding changed code from the reviewer #1511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
fda1970
a2830cd
3054d0b
f8f235a
775c423
03267ea
70e478b
48e31d5
b0b358b
ac76ad7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1186,6 +1186,12 @@ def timeout(*args, **kwargs): | |
| assert len(detail.splitlines()[-1]) <= runners.TAIL_CHARS and "waiting for proxy" not in fallback | ||
|
|
||
|
|
||
| def test_inspection_accepts_the_reviewer_patch_command() -> None: | ||
| command = (f"git -C /repo diff --no-color --no-ext-diff --no-textconv --text " | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Exercise the command that The test hand-copies the Git options, so it will still pass if |
||
| f"--ignore-submodules=none --submodule=short {'a' * 40} {'b' * 40}") | ||
| assert runners._inspection_commands(command, "/repo") == [("diff", "a" * 40, "b" * 40)] | ||
|
|
||
|
|
||
| def test_split_diff_respects_budget_and_summarizes_deleted_file() -> None: | ||
| deleted = ( | ||
| "diff --git a/gone.py b/gone.py\n" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -205,6 +205,37 @@ def test_start_reports_git_failure_with_command(repo: Path) -> None: | |
| assert info.value.tail | ||
|
|
||
|
|
||
| def _commit_files(repo: Path, files: dict[str, bytes | None]) -> str: | ||
| for name, content in files.items(): | ||
| (repo / name).write_bytes(content) if content is not None else (repo / name).unlink() | ||
| git(repo, "add", "-A", "--", *files) | ||
| git(repo, "commit", "-q", "-m", "change") | ||
| return git(repo, "rev-parse", "HEAD").strip() | ||
|
|
||
|
|
||
| def test_diff_since_shows_changes_the_reviewed_files_try_to_hide(git_repo: Path) -> None: | ||
| base = _commit_files(git_repo, {"attr.py": b"old\n", "nul.py": b"old\n"}) | ||
| git(git_repo, "update-index", "--add", "--cacheinfo", f"160000,{base},a-sub") | ||
| _commit_files(git_repo, { | ||
| ".gitattributes": b"attr.py -diff\nnul.py binary\n", "attr.py": b"new = 'attr hunk'\n", | ||
| "nul.py": b"new = 'nul hunk'\x00\n", "image.png": b"\x89PNG\r\n\x1a\n\x00\xff\xfe", | ||
| ".gitmodules": b'[submodule "a-sub"]\n\tpath = a-sub\n\tignore = all\n'}) | ||
| diff = worktree.diff_since(git_repo, base) | ||
| assert b"Binary files" not in diff and f"+Subproject commit {base}".encode() in diff | ||
| assert b"+new = 'attr hunk'" in diff and b"+new = 'nul hunk'\x00" in diff and b"+\x89PNG\r" in diff | ||
|
|
||
|
|
||
| def test_split_diff_summarizes_only_files_git_reports_deleted(git_repo: Path) -> None: | ||
| from loopzero.runners import render_patch, split_diff # keeps the shared import block untouched | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion: Keep the runner imports at module scope The inline comment says the local import preserves the shared import block, but this delta edits that block too. Import |
||
| base = _commit_files(git_repo, {"gone.py": b"old\n", "padded.py": b"old\n", "carriage.py": b"old\n"}) | ||
| _commit_files(git_repo, {"gone.py": None, "padded.py": b"new = 'padded hunk'\n++ /dev/null\n" + b"x\n" * 300, | ||
| "carriage.py": b"new \rdiff --git a/carriage.py b/carriage.py\rdeleted file mode 100644\r" | ||
| + b"y\n" * 300}) | ||
| joined = "".join(split_diff(render_patch(worktree.diff_since(git_repo, base)), 1_000)) | ||
| assert "+++ /dev/null" in joined and "+new = 'padded hunk'" in joined and "+new \r" in joined | ||
| assert "gone.py: deleted, 1 lines" in joined and joined.count(": deleted, ") == 1 | ||
|
|
||
|
|
||
| def test_dirty_head_and_diff(repo: Path) -> None: | ||
| wt = worktree.start(repo, "work", "main") | ||
| base = worktree.base_sha(wt) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.