code.gitea.io/gitea@v1.19.3/modules/git/repo_commitgraph.go (about)

     1  // Copyright 2022 The Gitea Authors. All rights reserved.
     2  // SPDX-License-Identifier: MIT
     3  
     4  package git
     5  
     6  import (
     7  	"context"
     8  	"fmt"
     9  )
    10  
    11  // WriteCommitGraph write commit graph to speed up repo access
    12  // this requires git v2.18 to be installed
    13  func WriteCommitGraph(ctx context.Context, repoPath string) error {
    14  	if CheckGitVersionAtLeast("2.18") == nil {
    15  		if _, _, err := NewCommand(ctx, "commit-graph", "write").RunStdString(&RunOpts{Dir: repoPath}); err != nil {
    16  			return fmt.Errorf("unable to write commit-graph for '%s' : %w", repoPath, err)
    17  		}
    18  	}
    19  	return nil
    20  }