Skip to content

Commit 4dc79f1

Browse files
docs: add origin note to README (#5)
Adds a brief **Origin** section to the README explaining that `git-testkit` was extracted from `git-fire` before launch and published as a standalone library. 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Documentation-only changes (README badges/origin note and new package-level `doc.go`) with no impact on runtime behavior. > > **Overview** > Adds README badges and a new **Origin** section describing `git-testkit`’s extraction from `git-fire`. > > Introduces a package-level `doc.go` with GoDoc describing the main entry points (`CreateTestRepo`, `NewScenario`, `SnapshotRepo`/`RestoreSnapshot`) and a short quickstart example. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 544db1b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Documentation** * Updated README: added status and reference badges and a new "Origin" section describing the project’s extraction and standalone release. * Added package-level documentation describing a test helper library for exercising real Git repositories, including primary helper entry points and guidance on using the helpers with the testing framework. <!-- end of auto-generated comment: release notes by coderabbit.ai --> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent bfdd233 commit 4dc79f1

2 files changed

Lines changed: 39 additions & 0 deletions

File tree

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# git-testkit
22

3+
[![CI](https://github.com/git-fire/git-testkit/actions/workflows/ci.yml/badge.svg)](https://github.com/git-fire/git-testkit/actions/workflows/ci.yml)
4+
[![Go Reference](https://pkg.go.dev/badge/github.com/git-fire/git-testkit.svg)](https://pkg.go.dev/github.com/git-fire/git-testkit)
5+
[![Go 1.22+](https://img.shields.io/badge/go-1.22+-blue.svg)](https://golang.org/dl/)
6+
[![Latest Release](https://img.shields.io/github/v/release/git-fire/git-testkit)](https://github.com/git-fire/git-testkit/releases/latest)
7+
[![MIT License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
8+
39
`git-testkit` provides helpers for writing Go tests that exercise real Git repositories.
410

511
## Why use this
@@ -113,6 +119,10 @@ func TestUsingSnapshot(t *testing.T) {
113119
- Helpers fail tests immediately (`t.Fatalf`) when git commands fail, so errors surface close to setup code.
114120
- When tests build large repo graphs repeatedly, prefer snapshot/restore to reduce total runtime.
115121

122+
## Origin
123+
124+
`git-testkit` was extracted from [git-fire](https://github.com/git-fire/git-fire) before its public launch and published as a standalone Go library. The test helpers had accumulated enough utility to be useful on their own, so they were split out to let other projects automate real Git repositories without depending on git-fire itself.
125+
116126
## Developer docs
117127

118128
- See `DEVELOPER_GUIDE.md` for:

doc.go

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// Package testutil provides helpers for writing Go tests that exercise real
2+
// Git repositories. Instead of mocking git command output, tests create actual
3+
// repositories on disk, apply operations through fluent builders, and assert
4+
// against real git state.
5+
//
6+
// The three main entry points are:
7+
//
8+
// - [CreateTestRepo] for quickly spinning up a single repository with files,
9+
// branches, and remotes already configured.
10+
// - [NewScenario] for building multi-repository topologies (local + bare
11+
// remote, diverged clones, worktrees, conflict states).
12+
// - [SnapshotRepo] / [RestoreSnapshot] for capturing expensive fixture state
13+
// once and restoring it cheaply across subtests.
14+
//
15+
// All helpers integrate with Go's testing.T: repositories are created inside
16+
// t.TempDir() and cleaned up automatically, and setup failures call t.Fatalf
17+
// so errors surface close to the fixture code rather than deep in assertions.
18+
//
19+
// # Quickstart
20+
//
21+
// func TestMyFeature(t *testing.T) {
22+
// repoPath := testutil.CreateTestRepo(t, testutil.RepoOptions{Name: "subject"})
23+
// testutil.RunGitCmd(t, repoPath, "checkout", "-b", "feature")
24+
// // exercise your code against repoPath
25+
// if testutil.IsDirty(t, repoPath) {
26+
// t.Fatal("expected clean repo")
27+
// }
28+
// }
29+
package testutil

0 commit comments

Comments
 (0)