Artifact 3ccc01e04109decdecdc159960c957caaac3a56696739661a07bf7c72536aba4:
- File
leaf/agent/clone.go
— part of check-in
[38efed7a12]
at
2026-08-12 20:50:57
on branch main
— chore(deps): migrate to go-libfossil v0.9.0 (#195)
* chore(deps): migrate to go-libfossil v0.9.0 (renamed module path)
- import path danmestas/libfossil → danmestas/go-libfossil everywhere - CloneOpts.ProjectCode removed upstream; assert via CloneResult instead - Timeline now takes TimelineOpts (cursor pagination, newest-first) - testutil.HasFossil removed; check FossilBinary() != ""
* ci: retrigger checks
---------
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> (user: [email protected], size: 1563) [annotate] [blame] [check-ins using]
package agent import ( "context" "fmt" libfossil "github.com/danmestas/go-libfossil" ) // cloneFromHub clones a fossil repo from hubURL into repoPath. The cloned // handle is closed before returning so subsequent libfossil.Open in New // reopens it through the same code path as a pre-existing repo. // // Used by New when Config.CloneFromHubURL is set and Config.RepoPath does // not yet exist on disk. Callers that need a clone helper independent of // agent construction can use this function directly via CloneRepo. func cloneFromHub(repoPath, hubURL string) error { return CloneRepo(context.Background(), repoPath, hubURL) } // CloneRepo clones a fossil repo from hubURL into repoPath. Standalone // helper that does not require an Agent instance — callers that need to // bootstrap a leaf repo before any agent exists can use it directly, // though most callers should prefer Config.CloneFromHubURL on agent.New. // // The cloned repo is closed before returning. Reopen via libfossil.Open // or simply construct an Agent that points at the same path. func CloneRepo(ctx context.Context, repoPath, hubURL string) error { if repoPath == "" { return fmt.Errorf("agent.CloneRepo: repoPath is required") } if hubURL == "" { return fmt.Errorf("agent.CloneRepo: hubURL is required") } transport := libfossil.NewHTTPTransport(hubURL) r, _, err := libfossil.Clone(ctx, repoPath, transport, libfossil.CloneOpts{}) if err != nil { return fmt.Errorf("clone %s -> %s: %w", hubURL, repoPath, err) } if r != nil { _ = r.Close() } return nil }