Artifact 83ea6048baae4b4ce0fc4eb5d0d9bc2ab643809377eb2841906ae8b1afaae0be:
- File
hub/commit.go
— part of check-in
[7536beb856]
at
2026-05-06 20:40:32
on branch trunk
— feat(hub): CommitOpts.Tags — attach tags at commit time (incl. branch=) (#148)
Plumbs libfossil's `Tags []TagSpec` primitive through `hub.CommitOpts` so callers can land a checkin on a non-current branch (or attach any other tag) without going around the EdgeSync API to libfossil.
Fossil branches are propagating tags: `branch=<name>` + `sym-<name>=*` together place a checkin on a branch. Exposing `Tags` rather than a git-flavored `Branch string` keeps the API fossil-native and is strictly more expressive — any tag (closed, release, custom) can be attached at commit time, not just branch creators.
Empty `Tags` preserves the existing trunk-default behavior; current callsites compile and run unchanged.
Closes #147 (user: [email protected], size: 2383) [annotate] [blame] [check-ins using]
package hub import ( "context" "time" ) // RevID is an opaque commit handle. type RevID string // FileToCommit names a file and its content for inclusion in a commit. type FileToCommit struct { Name string Content []byte // Perm is the libfossil-style file permission marker. The empty string // means default (regular file); "x" marks the file executable so the // resulting manifest's F-card carries the executable bit. Other libfossil // perm markers (e.g. "l" for symlinks) are passed through verbatim. Perm string } // CommitOpts configures Hub.Commit / Repo.Commit. type CommitOpts struct { Files []FileToCommit Message string Author string // fossil user; required // Time is the commit timestamp. The zero value defaults to time.Now().UTC() // at commit time; callers that need reproducible seeded commits (e.g. a // production daemon bootstrapping a hub repo from on-disk content) should // pass an explicit value. Time time.Time // Tags, when non-empty, are attached to the resulting checkin manifest. // Tags are libfossil's primitive — fossil "branches" are themselves // propagating "branch=<name>" + "sym-<name>" tag pairs. To land a commit // on branch "agent/abc123": // // Tags: []TagSpec{ // {Name: "branch", Value: "agent/abc123"}, // {Name: "sym-agent/abc123", Value: "*"}, // } // // Empty preserves current behavior (commit to current branch, no extra tags). Tags []TagSpec } // TagSpec describes a tag attached at commit time. Mirrors libfossil's // underlying tag primitive; pass these via CommitOpts.Tags to attach // arbitrary tags (including the propagating branch-tag pair that creates // or advances a fossil branch) on the resulting checkin. type TagSpec struct { Name string Value string } // Commit commits a set of files to the hub repo. func (h *Hub) Commit(ctx context.Context, opts CommitOpts) (RevID, error) { return h.repo.Commit(ctx, opts) } // Read returns the contents of path at the current trunk tip. func (h *Hub) Read(ctx context.Context, path string) ([]byte, error) { return h.repo.Read(ctx, path) } // ReadAt returns the contents of path at rev. rev may be a branch name // (e.g. "trunk"), a tag, or a RevID returned from Commit. func (h *Hub) ReadAt(ctx context.Context, rev RevID, path string) ([]byte, error) { return h.repo.ReadAt(ctx, rev, path) }