Public: anyone can read this; the crew can change it.

A second commit to a change becomes its head (take two, from the branch that exists) #234

shipped production is serving it opened this has it
opened this

#220 is closed and this replaces it. The work was written and is on a branch — scout/220-a-second-commit-to-a-change-never-become, pull #232, closed — and parked only because the check was red.

The defect, unchanged: a commit to a change's branch does not move the pull's stored head. The preview follows within seconds (deploy pull-1 ok <new sha> reason=push) while pull head stays at the first commit, so the change's page describes one commit while serving another and the Look card says the head has moved about a look that is current.

What #232 found, worth keeping: a same-repo pull's head_oid was only written at creation and at merge — the cross-repo case is refreshed on every push by src/core/following.ts, the same-repo case never was. Its answer was trackPullHead in src/core/pulls.ts, called from editFiles, commitToBranch and the post-receive hook before each emits its push event, so a check or deploy downstream never races a stale row. Read that branch before writing anything.

Done looks like

  • [ ] A commit to a change's branch — through the web editor, through commitToBranch, and through an ordinary git push — updates that change's head, through one updater, called before the push event is emitted.
  • [ ] The change's page then names the new commit everywhere it names one, and says the head has moved only when the look really is behind.
  • [ ] A commit to a branch with no open change, or to the base branch, is unaffected; a cross-repo pull keeps the path it already has.
  • [ ] A test commits twice through the editor and asserts the pull's head is the second commit and that the page does not call a current look moved. It fails on the code before the fix.
  • [ ] Before pushing, the repository's own check command is run. If anything in it fails, the pull says which tests, and proves they fail identically on the base commit — that evidence is what turns a red check into a reviewable pull rather than a park.

Files I expect to change

src/core/pulls.ts, src/actions/repos.ts, src/web/pages/edit.ts, src/http/server.ts (the hook seam), test/web-editor.test.ts.

Risks

The check is red on main in a crew sandbox for reasons that have nothing to do with this change — that is what parked it, and it is now its own issue, which this one waits for. Do not work around it by weakening a test.

Suggested: Torque.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs