Skip to content

feat: replicate with a different gh account per side - #13

Merged
vmvarela merged 1 commit into
masterfrom
feat/11-source-target-accounts
Oct 24, 2026
Merged

vmvarela merged 1 commit into
masterfrom
feat/11-source-target-accounts

Conversation

@vmvarela

Copy link
Copy Markdown
Owner

Closes #11.

What changed

gh replicate can now read the source and write the destination with two different accounts that are already authenticated in gh.

gh replicate --source-account alice --target-account bob alice/project bob/project-replica
  • Both flags are optional and independent; without them nothing changes.
  • Each side gets its own api.RESTClient and its own token, injected into that side's Git subprocesses after stripping inherited GH_TOKEN/GITHUB_TOKEN.
  • Before the clone, both sides prove their identity with GET /user. A token that authenticates as another account aborts with a message naming both logins and stating that nothing was changed.
  • The active gh account, credential storage and global Git configuration are never modified.

How tested

  • go test -race ./...: 35 tests, including the new coverage for token isolation in the Git environment, account resolution failures, identity enforcement and the abort-before-write path.
  • gofmt, go vet, go build, go mod tidy clean; govulncheck reports no vulnerabilities with the Go version pinned in CI.
  • Real replication between two authenticated accounts on github.com: reads were made with the source account, and every release and asset in the destination was created by the target account. The source account has no access to the destination, and the global active account was unchanged afterwards.

Notes

GHES and cross-host replication remain out of scope (#4).

--source-account and --target-account select already-authenticated github.com
accounts independently. Each side gets its own API client and its own token in
the Git subprocesses, and both logins are proven with GET /user before the
clone, so a mixed-up credential fails before anything is written. The active
gh account, credential storage and global Git configuration are untouched, and
the single-account path is unchanged when neither flag is given.
@vmvarela
vmvarela merged commit b3c092a into master Oct 24, 2026
9 checks passed
@vmvarela
vmvarela deleted the feat/11-source-target-accounts branch October 24, 2026 10:14
@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.

Support two different gh accounts for source and destination

1 participant