Uh oh!
There was an error while loading. Please reload this page.
feat: auto-create library repo via go-github in librarystore (#459) - #461
Merged
antoinetoussaint-byte merged 2 commits intoAug 23, 2026
Conversation
Publish assumed the target repository already existed and errored out otherwise. Repository creation is a GitHub platform operation git cannot perform, so it now runs a "create if missing" step over the go-github API before the existing git clone/commit/tag/push path. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…able (#459) Review of the initial auto-create change surfaced defects where the "safe-looking" defaults quietly broke the feature. Fixes, highest severity first: - Split auth: the API token created the repo but never reached git, so a host authenticated only by GITHUB_TOKEN created a repo it then could not clone/push. The resolved credential now also authenticates github.com HTTPS git ops, injected via GIT_CONFIG_* env (scoped to github.com, kept out of argv) so create and content-push share one credential. - Visibility: repos were created private, which makes the `go get github.com/owner/name-go` install hint Publish returns fail for consumers — contradicting the store's own contract. Repos are now created public. - Default branch: created empty, so the published default branch was whatever the publishing host's init.defaultBranch happened to be. AutoInit makes it deterministic and host-independent. - Idempotency: a create losing the lookup/create race (422) is now the idempotent success the contract promises, not a misleading "needs scope" error. - Owner type: Create routed everything through the org endpoint, 404ing for a user owner the struct documents as supported; owner type now selects the org vs authenticated-user endpoint. - Testability: the token source is injectable, so the no-token degrade path and the real ensureRepository wiring are covered without shelling out to `gh`. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes#459.
Summary
pkg/librarystorepublished library content over raw git but assumed the target repository already existed, erroring out otherwise. Repository creation is a GitHub platform operation git can't perform, soPublishnow runs a "create if missing" step over thego-github/v89API (already a direct dependency) before the unchanged git clone/commit/tag/push flow.Repositories.Get), org-owned, and private by default so an automated publish never makes an org's history public as a side effect. A non-404 lookup error is surfaced rather than mistaken for a missing repo.Repositories.Createfails with an actionable error naming the missing scope.The token/client plumbing (
GITHUB_TOKEN/GH_TOKEN, thengh auth token) mirrors the existing resolver incmd/agents/versions.go; consolidating both into a shared helper is #457's job and is intentionally left out of scope here.Test plan
TestGitHubStorePublishCreatesMissingRepositoryBeforeCloning— creation runs before the clone; the git path then publishes normally.TestGitHubStorePublishAbortsWhenRepositoryCreationFails— a creation failure aborts before any git operation.TestEnsureRepositoryExists— existing repo is a no-op, absent repo is created org-owned, a non-404 lookup surfaces an error, and a no-scope token yields an actionable error (httptest, real go-github).go build ./pkg/librarystore/,go vet ./pkg/librarystore/,go test ./pkg/librarystore/all pass; nogo.mod/go.sumchanges.🤖 Generated with Claude Code