github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/git/repo_commitgraph.go (about) 1 // Copyright 2023 The GitBundle Inc. All rights reserved. 2 // Copyright 2017 The Gitea Authors. All rights reserved. 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file. 5 6 package git 7 8 import ( 9 "context" 10 "fmt" 11 ) 12 13 // WriteCommitGraph write commit graph to speed up repo access 14 // this requires git v2.18 to be installed 15 func WriteCommitGraph(ctx context.Context, repoPath string) error { 16 if CheckGitVersionAtLeast("2.18") == nil { 17 if _, _, err := NewCommand(ctx, "commit-graph", "write").RunStdString(&RunOpts{Dir: repoPath}); err != nil { 18 return fmt.Errorf("unable to write commit-graph for '%s' : %w", repoPath, err) 19 } 20 } 21 return nil 22 }