Skip to content

feat: set the destination default branch to match the source - #18

Merged
vmvarela merged 2 commits into
masterfrom
feat/17-destination-default-branch
Oct 24, 2026
Merged

vmvarela merged 2 commits into
masterfrom
feat/17-destination-default-branch

Conversation

@vmvarela

@vmvarela vmvarela commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

What

The destination repository's default branch now follows the source.

repository carries default_branch (omitted when the source reports none), so the metadata update that already runs after the refs push sends it along with description and homepage. The branch exists by then because all source branches were pushed first; if GitHub still rejects the update, the repository settings most likely do not allow the token to change them.

Why

A destination created with main kept main as its default even after master arrived from the source, so opening the mirror showed a branch the source does not use. Deleting destination-only branches stays out of scope; this only fixes which existing branch is the default.

How tested

  • TestRunReplicatesIntoDestination now serves a source default of master and a destination default of main, then asserts the captured metadata update carries master, proving the value travels from the source read through preflight into the update that follows the push.
  • TestSyncMetadataSetsDestinationDefaultBranch keeps the narrow unit check on the request body.
  • go test -race -count=1 ./...: 49 tests pass, including the offline entrypoint suite.
  • gofmt -l . clean, GOTOOLCHAIN=go1.27.3 go vet ./... clean, go build ok, git diff --check clean.

Known limit: changing a default branch needs repository administration and can be restricted by rulesets, so a failure is reported as an error after the refs push, leaving a partial replication. Branch protections are neither copied nor bypassed.

Out of scope

Deleting destination-only branches, branch protection, visibility and any other repository setting. A dry run still writes nothing.

Closes #17

@vmvarela
vmvarela merged commit bd8b8dc into master Oct 24, 2026
9 checks passed
@vmvarela
vmvarela deleted the feat/17-destination-default-branch branch October 24, 2026 11:42
@vmvarela vmvarela added the enhancement New feature or request label Oct 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set the destination default branch to match the source

1 participant