Skip to content

feat(review): add --base to review local changes against a named revision - #108

Open
swayamg20 wants to merge 1 commit into
prooflinedev:mainfrom
swayamg20:feat/review-base
Open

swayamg20 wants to merge 1 commit into
prooflinedev:mainfrom
swayamg20:feat/review-base

Conversation

@swayamg20

Copy link
Copy Markdown

Summary

  • proofline review --base REVISION reviews the working tree and local commits against the merge-base of HEAD and the named revision, instead of the upstream or <remote>/HEAD.
  • This helps anyone reviewing a branch they have already pushed, and anyone working on stacked branches. After git push -u, the base became HEAD, so the pushed commits were left out unless you ran git branch --unset-upstream. On a stacked branch with no upstream, the default branch was the base, so the parent branch's commits were reviewed again. Naming the base fixes both.
  • A base that no remote-tracking branch contains is refused before any request, with a message telling you to push the revision.

Decisions

  • The base is merge-base(HEAD, REVISION). This matches the default behavior and how GitHub diffs a pull request, so a parent branch that has moved on does not show up as reverted.
  • The revision is resolved with the existing resolve helper. An empty value, a value starting with -, or a value that names no commit is refused with the same error as --commit and --range.
  • git for-each-ref --contains <merge-base> refs/remotes/ must find a ref before anything is sent, because GitHub must have base_commit_sha. A ref on any remote counts, so fork setups work; the server still verifies the base.
  • Unrelated histories get their own error instead of a bare git merge-base failure.
  • --base conflicts with --pr, --commit, --range and --files. It works with --staged, --include-untracked, --path, --verify, --allow-path and --fail-on.

Testing

  • cargo fmt --check: pass
  • cargo clippy --locked --all-targets -- -D warnings: pass
  • cargo test --locked --test local_patch: 18 passed, including 4 new tests. They cover a pushed branch vs the default base; a stacked branch; unpushed and unrelated bases refused with no requests; and unknown revisions, --prefixed revisions and flag conflicts refused with no requests. The new tests failed before the change.
  • cargo test --locked --no-fail-fast: 158 passed, 1 failed. The failure is agent_install::unattended_registration_preserves_settings_and_uses_the_installed_binary (macOS /var vs /private/var), which fails the same way on main.
  • Manual check with the built binary against a bare remote and a stub server:
    • On a branch pushed with -u, the default sent the branch head as the base with 1 file. --base main sent the main commit and included the pushed commit's file.
    • --base parent with an unpushed parent exited 1 with no requests. After git push, it sent the parent commit.

Scope

  • Hooks, --range, --commit and pull-request review are unchanged; hooks keep the automatic base.
  • The no-base error still only points at Git configuration, because hooks share it and cannot take --base.
  • No changes to openapi.public.json, generated code or workflows.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant