From 73b033c3e1330bdf91a54b82ee546c4bdfcbe6ea Mon Sep 17 00:00:00 2001 From: AJ ONeal Date: Sun, 19 Apr 2026 22:54:21 -0600 Subject: [PATCH] refactor: remove Run from gitshallow.Repo MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Polling loop (ticker + Sync check) is generic to any update source — git HEAD, HTTP ETag, file mtime. Caller drives the loop. --- net/gitshallow/gitshallow.go | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/net/gitshallow/gitshallow.go b/net/gitshallow/gitshallow.go index 1681021..35030eb 100644 --- a/net/gitshallow/gitshallow.go +++ b/net/gitshallow/gitshallow.go @@ -1,14 +1,12 @@ package gitshallow import ( - "context" "fmt" "os" "os/exec" "path/filepath" "strings" "sync" - "time" ) // Repo manages a shallow git clone used as a periodically-updated data source. @@ -58,28 +56,6 @@ func (r *Repo) Init(lightGC bool) error { return r.invokeCallbacks() } -// Run periodically syncs the repo and invokes callbacks when HEAD changes. -// Blocks until ctx is done. -// lightGC=false (zero value) runs aggressive GC with immediate pruning to minimize disk use. -// Pass true to skip both when the periodic GC is too slow for your workload. -func (r *Repo) Run(ctx context.Context, lightGC bool) { - ticker := time.NewTicker(47 * time.Minute) - defer ticker.Stop() - - for { - select { - case <-ticker.C: - if updated, err := r.Sync(lightGC); err != nil { - fmt.Fprintf(os.Stderr, "error: git sync: %v\n", err) - } else if updated { - fmt.Fprintf(os.Stderr, "git: repo updated\n") - } - case <-ctx.Done(): - return - } - } -} - // Clone performs a shallow clone (--depth N --single-branch --no-tags). func (r *Repo) Clone() (bool, error) { r.mu.Lock()