Repository navigation
Review conflict resolutions in the available delta round #1663
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
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 |
|---|---|---|
|
|
@@ -848,11 +848,12 @@ def cmd_review(args: argparse.Namespace, wt: Path, config: Config) -> int: | |
| candidates = [family for family in config.reviewers if family not in authors] | ||
| if result.fallback and not _published_fallback(result.fallback, candidates, excluded): | ||
| raise CliError("saved fallback note is not in the published form; run without --repost") | ||
| allowed, _ = _decide_kind( | ||
| allowed, reviewed = _decide_kind( | ||
| _pr_markers(reviews, head, config.review_publishers, repo=config.repo, number=pr.number), head | ||
| ) | ||
| if allowed != kind: | ||
| raise CliError("saved review kind differs from the remaining review budget") | ||
| _delta_patch(wt, config, reviewed, head, pr.number) | ||
| else: | ||
| try: | ||
| result = _run_review(wt, config, head, kind, reviewed, args.model, args.effort, | ||
|
|
@@ -1003,12 +1004,27 @@ def _confirm_review(wt: Path, config: Config, pr: github.PR, result: ReviewResul | |
| return True | ||
|
|
||
|
|
||
| def _delta_merge_recovery(wt: Path, reviewed: str, merge: str) -> str: | ||
| pre_merge = _git(wt, "rev-parse", f"{merge}^1") | ||
| if not _is_ancestor(wt, reviewed, pre_merge): | ||
| return f"replay the fixes on the reviewed head {reviewed[:12]}" | ||
| return (f"save the current tip on a backup branch, use `git reset --hard {pre_merge}`, " | ||
| "and cherry-pick any later fixes from the backup") | ||
| def _delta_patch(wt: Path, config: Config, since: str | None, head: str, number: int | None) -> bytes: | ||
| if since is None: | ||
| return b"" | ||
| if not _is_ancestor(wt, since, head): | ||
| raise CliError( | ||
| f"reviewed head {since[:12]} is not an ancestor of this branch. Find the original tip with `git reflog`. " | ||
| "Back up your branch, reset to that tip and replay later fixes. To publish the restored head, " | ||
| f"run `loopzero pr`, then `loopzero review` before merging {config.base_branch}, or open a new PR" | ||
| ) | ||
| if not worktree.merges_since(wt, since): | ||
| return worktree.diff_since(wt, since) | ||
| patch = (eligibility.base_merge_material(config.repo, number, since, head, config.base_branch, clean=False) | ||
| if number is not None else None) | ||
| if patch is None: | ||
|
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: Resource-bound and runtime Git failures are reported as unverifiable merge history
|
||
| raise CliError( | ||
| f"could not verify merge history: {since[:12]} must be on the first-parent history and " | ||
| f"merged parents must come from {config.base_branch}. Save your work, then replay the fixes " | ||
| f"on the reviewed head {since[:12]}, including resolution edits. Push with `loopzero pr` " | ||
| "and run `loopzero review`, or open a new PR" | ||
| ) | ||
| return patch | ||
|
|
||
|
|
||
| def _run_review( | ||
|
|
@@ -1018,23 +1034,8 @@ def _run_review( | |
| ) -> ReviewResult: | ||
| lineage_base = _primary_base(wt, config) | ||
| since = reviewed if kind == "delta" else lineage_base | ||
| if kind == "delta" and not _is_ancestor(wt, since, head): | ||
| raise CliError( | ||
| f"reviewed head {since[:12]} is not an ancestor of this branch. Find the original " | ||
| "branch tip with `git reflog`. Save the current tip on a backup branch, then use " | ||
| "`git reset --hard <original-tip>` and replay any later fixes. To publish the restored " | ||
| f"head, run `loopzero pr`, then `loopzero review` before merging {config.base_branch}, or open a new PR " | ||
| "from the current branch" | ||
| ) | ||
| if kind == "delta" and (merges := worktree.merges_since(wt, since)): | ||
| recovery = _delta_merge_recovery(wt, since, merges[0]) | ||
| raise CliError( | ||
| f"merge commit {merges[0][:12]} since the reviewed head {since[:12]} would put the " | ||
| f"merged-in changes in the delta material. To recover, {recovery}. " | ||
| f"To publish the recovered head, run `loopzero pr`, then `loopzero review` " | ||
| f"before merging {config.base_branch} again" | ||
| ) | ||
| patch = worktree.diff_since(wt, since) | ||
| patch = (_delta_patch(wt, config, since, head, publication[1] if publication else None) | ||
| if kind == "delta" else worktree.diff_since(wt, since)) | ||
| diff = runners.render_patch(patch) | ||
| task = worktree.task_text(wt) | ||
| authors = runners.author_families(wt, head, lineage_base) | ||
|
|
||
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: Repost builds and discards the full delta patch just to validate history
On
--repost,_delta_patch(wt, config, reviewed, head, pr.number)runs only for its exceptions. For merged histories this means a GitHub API call, a depth-200 isolated fetch and a fulllog --remerge-diff, and the resulting bytes are thrown away. It also does not compare the material against what the saved review actually saw. As written, a failure on an unrelated bound blocks reposting a review that was already produced. Consider a cheaper check that only verifies the history (for example, an optional flag onbase_merge_materialthat stops before runninggit log). Alternatively, save the reviewed material's byte length or hash with the review and compare that, so the check binds to the reviewed material.