This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

knotmirror/git: create commit-graph after sync

This improves total commit count query about 10x.
10s -> 1s from kernel repository.

Signed-off-by: Seongmin Lee <git@boltless.me>

author
Seongmin Lee
committer
oppiliappan
date (Jul 21, 2026, 4:40 PM +0100) commit a673a0f1 parent 22c5bff0 change-id nuqqqkys
+12
+12
knotmirror/git.go
··· 4 4 "context" 5 5 "errors" 6 6 "fmt" 7 + "log" 7 8 "net/url" 8 9 "os" 9 10 "os/exec" 10 11 "path/filepath" 11 12 "regexp" 12 13 "strings" 14 + "time" 13 15 14 16 "github.com/go-git/go-git/v5" 15 17 gitconfig "github.com/go-git/go-git/v5/config" ··· 77 79 } 78 80 return fmt.Errorf("running 'git clone --mirror %s': %w\n%s", url, err, msg) 79 81 } 82 + writeCommitGraph(ctx, path, 30 * time.Second) 80 83 return nil 81 84 } 82 85 ··· 129 132 } 130 133 } 131 134 135 + writeCommitGraph(ctx, path, 3 * time.Second) 132 136 return nil 137 + } 138 + 139 + func writeCommitGraph(ctx context.Context, path string, timeout time.Duration) { 140 + ctx, cancel := context.WithTimeout(ctx, timeout) 141 + defer cancel() 142 + if err := exec.CommandContext(ctx, "git", "-C", path, "commit-graph", "write", "--reachable", "--split").Run(); err != nil { 143 + log.Println("failed to run commit-graph", err) 144 + } 133 145 } 134 146 135 147 func (c *CliGitMirrorManager) Sync(ctx context.Context, repo *models.Repo) error {