bootstrap: push source HEAD's branch first

main

Commit

Soph4mo ago

Hosts that pick the default branch from the first push on a fresh repo (GitHub, GitLab among them) end up with whatever branch sorted first alphabetically in our bootstrap push order — often wrong. Reorder push commands in bootstrap.Execute so the source HEAD's branch (e.g. refs/heads/main) is sent first, regardless of alphabetical order with other branches in scope.

hoistSourceHeadCommand is a small helper that moves the matching command to position 0; no-op when source HEAD is empty (detached source), not in cmds (filtered out by --branch / --map), or already first.

Batched bootstrap already orders trunk-first via orderTrunkFirst in planBatches, so the batched path inherits this for free — the first checkpointed branch batch carries source-HEAD's branch.

Integration test asserts a sync with both refs/heads/alpha (sorts first alphabetically) and refs/heads/master (the HEAD target) pushes master as the first ref command. Unit test covers the helper's edge cases (already-first, empty head, missing, single-command).

Addresses #45 for the GitHub/GitLab common case.

Co-Authored-By: Claude Opus 4.7 (1M context) noreply@anthropic.com Entire-Checkpoint: 3b20be920ba5