Artifact e643ad263a8a1649e8c86e029e180a0fd0f1624f1e2665508a5a99f5649b6bcd:
- File
examples/embed-repo-api/README.md
— part of check-in
[f5744359d3]
at
2026-04-19 16:30:54
on branch trunk
— Initial open source release
libfossil is a pure-Go implementation of the Fossil SCM, reading and writing the same .fossil SQLite repository format as upstream Fossil.
This is the first public release of code that previously lived in a private repository. The module path is github.com/danmestas/libfossil and the binary is named libfossil to avoid $PATH collisions with upstream fossil.
Included: - Repo lifecycle (create, clone), checkout/checkin, timeline, merge, diff, annotate, shun, tag, branch, bisect, stash, undo/redo - Sync-over-HTTP protocol (client and handler) - Two SQLite drivers: modernc (pure Go, default) and ncruces (wasm-capable) - Observer interfaces (SyncObserver, CheckoutObserver) with an optional OpenTelemetry implementation in observer/otel (separate submodule) - Deterministic simulation testing harness with BUGGIFY fault injection - Kong-based embeddable CLI under cli/ and a standalone binary under cmd/libfossil/ (user: [email protected], size: 1133) [annotate] [blame] [check-ins using]
# embed-repo-api A minimal example showing how to embed `libfossil` as a library in a Go application. It walks the basic repo lifecycle: 1. Register the default pure-Go SQLite driver via blank import (`_ "github.com/danmestas/libfossil/db/driver/modernc"`). 2. Create a new `.fossil` repository in a temp directory with `libfossil.Create`. 3. Close the handle returned by `Create` and re-open the file from disk with `libfossil.Open` to show the two calls are distinct. 4. Make one commit via `repo.Commit`, then read back: - the `project-code` config value (`repo.Config`) - the timeline of checkins (`repo.Timeline`) - the files in the manifest (`repo.ListFiles`) 5. Close the repo and remove the temp directory. ## Running This example lives inside the root `github.com/danmestas/libfossil` module, so no separate `go.mod` is needed. From the repo root: ``` go run ./examples/embed-repo-api ``` or: ``` go build ./examples/embed-repo-api ``` Expected output includes log lines for the created repo path, the commit RID and UUID, the `project-code`, one timeline entry, and one file entry (`hello.txt`).