Simplify after fifth review: dedupe, fold tag/other walk, reuse helpers · Entire

Simplify after fifth review: dedupe, fold tag/other walk, reuse helpers

39055c0→main·

Soph·2mo ago·9 files·+121 added/-180 removed

Fifth review pass surfaced a few real wins after the obvious dedup op opportunities had landed in earlier passes:

Net: -59 lines, all tests still green.

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

Sessions

0c2a854b8908View transcript

[?
do we have integration tests?Claude Code·Opus 4.7[1m]·1 step](/content/gh/entireio/git-sync/session/d0406407-d612-489d-b375-1372d062af82#timeline-0c2a854b8908/index.html)

Changes

9

// CLI smoke test for --all-refs: covers cobra flag parsing through the full
// sync pipeline so wiring breaks fail at the cmd layer, not just integration.
// Smoke test: cobra flag parsing through the full sync pipeline.
func TestRun_Sync_AllRefsSmokeTest(t *testing.T) {
    sourceRepo, sourceFS := newSourceRepo(t)
    makeCommits(t, sourceRepo, sourceFS, 2)

head, err := sourceRepo.Reference(plumbing.NewBranchReferenceName(testBranch), true)
    if err != nil {
        t.Fatalf("resolve source head: %v", err)
    }
    notesRef := plumbing.ReferenceName("refs/notes/commits")
    if err := sourceRepo.Storer.SetReference(plumbing.NewHashReference(notesRef, head.Hash())); err != nil {
        t.Fatalf("set source notes ref: %v", err)
    }
    head := syncertest.SetRefAtBranch(t, sourceRepo, notesRef, testBranch)

targetRepo, err := git.Init(memory.NewStorage())
    if err != nil {
        t.Fatalf("expected refs/notes/commits on target: %v", err)
    }
    if gotNotes.Hash() != head.Hash() {
        t.Fatalf("target notes hash = %s, want %s", gotNotes.Hash(), head.Hash())
    }
    assertHeadsMatch(t, sourceRepo, targetRepo, testBranch)
}

// replicate must keep strict failure semantics — its contract is "target matches source" — so --all-refs must NOT bundle BestEffort the way it does for sync. A target ng on any ref must surface as a non-nil error. // replicate's --all-refs must not bundle BestEffort the way sync's does. func TestRun_Replicate_AllRefsKeepsStrictFailureOnNg(t *testing.T) { sourceRepo, sourceFS := newSourceRepo(t) makeCommits(t, sourceRepo, sourceFS, 1) firstHead, err := sourceRepo.Reference(plumbing.NewBranchReferenceName(testBranch), true) if err != nil { t.Fatalf("resolve first head: %v", err) } notesRef := plumbing.ReferenceName("refs/notes/commits") if err := sourceRepo.Storer.SetReference(plumbing.NewHashReference(notesRef, firstHead.Hash())); err != nil { t.Fatalf("set source notes ref: %v", err) } syncertest.SetRefAtBranch(t, sourceRepo, notesRef, testBranch)

targetRepo, err := git.Init(memory.NewStorage()) if err != nil { t.Fatalf("failed to initialize target repo: %v", err) }

// Test logic here... }