Repository navigation
Preserve review summaries when check refreshes a PR #1099
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
2bebc1d
fdfe115
413f2b5
e935bf9
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 |
|---|---|---|
|
|
@@ -393,7 +393,8 @@ def test_pr_body_is_unchanged_when_checks_are_unchanged(wt: Path, gh: FakeGh, ca | |
| before = len(gh.calls) | ||
| assert run(capsys, command)[0] == 0 | ||
| history = HISTORY_CALLS if command == "pr" else [] | ||
| assert [c["argv"][:2] for c in gh.calls[before:]] == history + LOOKUP_CALLS | ||
| refresh = [["api", f"repos/{REPO}/pulls/7"]] if command == "pr" else [] | ||
| assert [c["argv"][:2] for c in gh.calls[before:]] == history + LOOKUP_CALLS + refresh | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("body", [ | ||
|
|
@@ -424,6 +425,25 @@ def test_check_refresh_replaces_previous_head_without_losing_evidence( | |
| assert text in updated | ||
|
|
||
|
|
||
| def test_delayed_check_preserves_review_summary(wt, gh, fake_bin, capsys, monkeypatch): | ||
|
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: Delayed-check test checks the re-read, not the lock
|
||
| head = prepare_review(wt, gh, fake_bin) | ||
| body = "# PR\n\n## Notes\nHuman evidence.\n" | ||
| gh.respond_pr_list([pr_json(headRefOid=head, body=body)]) | ||
| git(wt, "push", "-q", "-u", "origin", "lz/t1") | ||
| update = cli._update_pr_checks | ||
|
|
||
| def delay(path, sha, config, pr): | ||
| assert run(capsys, "review")[0] == 0 | ||
| live = json.loads(gh.calls[-1]["--input"])["body"] | ||
| gh.respond(f"api repos/{REPO}/pulls/7", rest_pr_json(pr_json(headRefOid=head, body=live))) | ||
| update(path, sha, config, pr) | ||
|
|
||
| monkeypatch.setattr(cli, "_update_pr_checks", delay) | ||
| assert run(capsys, "check")[0] == 0 | ||
| final = json.loads(gh.calls[-1]["--input"])["body"] | ||
| assert all(text in final for text in ("Human evidence.", "Recorded for", "- primary, claude")) | ||
|
|
||
|
|
||
| @pytest.mark.parametrize("command,exit_code", [("check", 0), ("pr", 1)]) | ||
| def test_malformed_live_markers_do_not_mask_check_verdict( | ||
| wt: Path, gh: FakeGh, capsys, command: str, exit_code: int, | ||
|
|
@@ -921,7 +941,7 @@ def test_pr_updates_existing_open_pr(wt: Path, gh: FakeGh, capsys) -> None: | |
| code, out, _ = run(capsys, "pr") | ||
| assert code == 0 and out == URL + "\n" | ||
| assert [c["argv"][:2] for c in gh.calls] == ( | ||
| HISTORY_CALLS + LOOKUP_CALLS + [["api", f"repos/{REPO}/pulls/7"]]) | ||
| HISTORY_CALLS + LOOKUP_CALLS + [["api", f"repos/{REPO}/pulls/7"]] * 2) | ||
| assert "(no `loopzero check` run recorded)" in gh.calls[-1]["--input"] | ||
|
|
||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion: Body built before the push is now only used for validation and draft creation
For an existing open PR,
existing/bodyat lines 637-638 are now discarded and rebuilt fromlive.bodyinside the lock (line 662). Building it early still has a purpose: it raises on malformed markers or an oversized body before the push, and the create-draft path uses it. A short comment saying so would stop a later cleanup from removing it, or from going back to reusing the stalebodyin the update branch.