test(source): cover untagged source add following the default branch - #83
Merged
Merged
Conversation
An untagged entry (no @ref) resolves against the repo's default branch by requesting commits/HEAD — main OR master, chosen server-side by GitHub, with no hardcoded branch name. Existing Add tests only used a tagged ref (@v1); the fetcher-level empty-ref case never ran through the full `source add` pipeline. Drive the real Puller.Add path against a real GitHubFetcher pointed at an httptest fake GitHub. Table-driven over two repos whose default branch tip differs; each asserts the manifest stores the untagged entry verbatim, the skill is vendored, the lock pins the default-branch tip SHA, and resolution goes through commits/HEAD (the fake 404s commits/main and commits/master, so guessing a branch name fails). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
🤖 AI Code Review✅ Clean review — no findings. (model: model: |
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 free
to 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.
What
Adds
TestSourceAdd_Untagged_FollowsDefaultBranch— a sanity integration test forsync-agents source addwith an untagged source (no@ref).Why
An untagged entry (e.g.
skill:foo/bar) is meant to track the repo's default branch. The implementation does this by resolving the empty ref toHEADand hittingGET /repos/{owner}/{repo}/commits/HEAD(fetcher.go:160-166) — no hardcoded"main", nogit ls-remote, so it followsmainormastertransparently (GitHub picks the default server-side).But coverage had a gap: existing
Addtests all used a tagged ref (@v1), and the empty-ref case was only exercised at theGitHubFetcher.ResolveRefunit level — never through the fullsource addpipeline (parse → manifest → resolve → fetch → extract → vendor → lock).How
Drives the real
Puller.Addpath against a realGitHubFetcherpointed at anhttptestfake GitHub (only GitHub is faked). Table-driven over two repos whose default-branch tip differs (main-tip vsmaster-tip). Each case asserts:SKILL.mdon disk).commits/HEAD— the fake server 404scommits/mainandcommits/master, so the test fails if the client ever guesses a branch name instead of asking for HEAD.Hermetic and offline (
TokenFnstubbed so it never shells out togh auth token).go vetclean; fullinternal/agent/sourcepackage green.Scope note
This proves the client requests HEAD correctly. Whether real GitHub's
commits/HEADreturns the default-branch tip is GitHub's contract, not something an httptest can assert — the test deliberately stops at the client boundary to stay offline. A bats-level version would need aSYNC_AGENTS_API_URL-style base-URL override on the CLI (currently the binary hardcodes&GitHubFetcher{}); happy to add that in a follow-up if we want end-to-end CLI coverage too.🤖 Generated with Claude Code