Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software:2222/vole.git

A free and open-source forge that lives in your Git repo.

#34

Let an author move their change request's head from the browser

merged · by keenan 13d ago · merged into main at 53ff967b by keenan 13d ago

keenan opened this 13d ago

Fixes #01M5XMWZ31K4607MHTXCD2VNZE.

Why

A change request names the exact commit under review, so a fixup pushed after it was opened is invisible until the head moves. The only mover was vole change update <id> --head <rev>, which writes refs/heads/vole — a write only a maintainer can make. A contributor could push to their own branch and open a request, but could not keep that request current; the alternatives were asking a maintainer or opening a second request and losing the discussion.

What changed

The request sidebar’s Review section now has a Move head to control, offered to the request’s author and to maintainers while the request is open:

Base   main
Head   43f98bcd
Move head to [ contrib/alice/fix-timeout ▾ ] [Update]

POST /r/{name}/requests/{id}/head resolves the chosen branch on the server and writes the new head with metadata.SetRequestHead, in one metadata commit, audited as web.request.head. Approvals stay in the tree as history and stop matching the new head, which is what a new head already meant.

The handler applies the rule the browser already applies when opening a request (CreateChangeRequest): the head must be a branch tip, and a contributor may only name a branch under refs/heads/contrib/<their-account>/ (access.IsContributorRef). Maintainers may name any normal branch. The picker uses the same filtered list, so it cannot offer a branch the handler would refuse.

metadata.SetRequestHead now refuses a closed or merged request. That is the same rule SetRequestCloses already states, and putting it in the writer means the CLI and the browser agree instead of the web handler owning it alone.

Checks

  • vole workflow check, vole workflow run verify (format, vet, build, govulncheck, packages, links, go test -race ./...).
  • New tests: TestContributorMovesTheirOwnRequestHead drives a contributor account through opening a request, pushing a fixup, moving the head, being refused a foreign branch, a maintainer moving the same request, and a closed request refusing the move. TestSetRequestHeadMovesOnlyAnOpenRequest pins the writer’s refusals for closed and merged requests.

Discussion (1)

keenan 13d ago

Rebased onto current main (8e1005e, which is 01M5XNPSY10NQSD45G1R8WDEHX merged) and moved the head to 53ff967. The only conflict was the expected one: both changes add fields to requestSidebarView and set them in the same return, and the sidebar’s Head row is directly above the new “Move head to” form. The resolution keeps both — HeadRefNote beside CanMoveHead/HeadBranches — and the template keeps the branch label and the form.

vole workflow run verify passes on the rebased tip. No approvals existed on the old head (0/1), so nothing was invalidated. The request now reports merge: clean against main; approving 53ff967 is enough to land it.