all repos

mugit @ 3adee8f

🐮 git server that your cow will love
2 files changed, 11 insertions(+), 8 deletions(-)
mirror: fetch with context
Author: Oleksandr Smirnov olexsmir@gmail.com
Committed at: 2026-02-13 00:07:29 +0200
Change ID: lrzokrooouylrokpwqyowkqrrxmtpxuo
Parent: b8bdd40
M internal/git/repo.go

@@ -1,6 +1,7 @@

package git import ( + "context" "errors" "fmt" "path/filepath"

@@ -202,22 +203,24 @@ }

return "", fmt.Errorf("unable to find master branch") } -func (g *Repo) Fetch() error { return g.fetch(nil) } +func (g *Repo) Fetch(ctx context.Context) error { + return g.fetch(ctx, nil) +} -func (g *Repo) FetchFromGithubWithToken(token string) error { - return g.fetch(&http.BasicAuth{ +func (g *Repo) FetchFromGithubWithToken(ctx context.Context, token string) error { + return g.fetch(ctx, &http.BasicAuth{ Username: "x-access-token", // this can be anything but empty Password: token, }) } -func (g *Repo) fetch(auth transport.AuthMethod) error { +func (g *Repo) fetch(ctx context.Context, auth transport.AuthMethod) error { rmt, err := g.r.Remote(originRemote) if err != nil { return fmt.Errorf("failed to get remote: %w", err) } - if err = rmt.Fetch(&git.FetchOptions{ + if err = rmt.FetchContext(ctx, &git.FetchOptions{ Auth: auth, Tags: git.AllTags, Prune: true,
M internal/mirror/mirror.go

@@ -84,7 +84,7 @@ }

return errors.Join(errs...) } -func (w *Worker) syncRepo(_ context.Context, repo *git.Repo) error { +func (w *Worker) syncRepo(ctx context.Context, repo *git.Repo) error { name := repo.Name() slog.Info("mirror: sync started", "repo", name)

@@ -100,12 +100,12 @@ return err

} if w.isRemoteGithub(remoteURL) && w.c.Mirror.GithubToken != "" { - if err := repo.FetchFromGithubWithToken(w.c.Mirror.GithubToken); err != nil { + if err := repo.FetchFromGithubWithToken(ctx, w.c.Mirror.GithubToken); err != nil { slog.Error("mirror: fetch failed (github)", "repo", name, "err", err) return err } } else { - if err := repo.Fetch(); err != nil { + if err := repo.Fetch(ctx); err != nil { slog.Error("mirror: fetch failed", "repo", name, "err", err) return err }