Skip to content

Commit 9c33aff

Browse files
zeripathbrechtvl
andauthored
Do not create commit graph for temporary repos (#23219) (#23302)
Backport #23219 When fetching remotes for conflict checking, skip unnecessary and potentially slow writing of commit graphs. In a test with the Blender repository, this reduces conflict checking time for one pull request from about 2s to 0.1s. --------- Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: Brecht Van Lommel <[email protected]>
1 parent a3e185b commit 9c33aff

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

services/pull/temp_repo.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,12 @@ func createTemporaryRepo(ctx context.Context, pr *issues_model.PullRequest) (str
6868
remoteRepoName := "head_repo"
6969
baseBranch := "base"
7070

71+
fetchArgs := []git.CmdArg{"--no-tags"}
72+
if git.CheckGitVersionAtLeast("2.25.0") == nil {
73+
// Writing the commit graph can be slow and is not needed here
74+
fetchArgs = append(fetchArgs, "--no-write-commit-graph")
75+
}
76+
7177
// Add head repo remote.
7278
addCacheRepo := func(staging, cache string) error {
7379
p := filepath.Join(staging, ".git", "objects", "info", "alternates")
@@ -109,7 +115,7 @@ func createTemporaryRepo(ctx context.Context, pr *issues_model.PullRequest) (str
109115
outbuf.Reset()
110116
errbuf.Reset()
111117

112-
if err := git.NewCommand(ctx, "fetch", "origin", "--no-tags").AddDashesAndList(pr.BaseBranch+":"+baseBranch, pr.BaseBranch+":original_"+baseBranch).
118+
if err := git.NewCommand(ctx, "fetch", "origin").AddArguments(fetchArgs...).AddDashesAndList(pr.BaseBranch+":"+baseBranch, pr.BaseBranch+":original_"+baseBranch).
113119
Run(&git.RunOpts{
114120
Dir: tmpBasePath,
115121
Stdout: &outbuf,
@@ -172,7 +178,7 @@ func createTemporaryRepo(ctx context.Context, pr *issues_model.PullRequest) (str
172178
} else {
173179
headBranch = pr.GetGitRefName()
174180
}
175-
if err := git.NewCommand(ctx, "fetch", "--no-tags").AddDynamicArguments(remoteRepoName, headBranch+":"+trackingBranch).
181+
if err := git.NewCommand(ctx, "fetch").AddArguments(fetchArgs...).AddDynamicArguments(remoteRepoName, headBranch+":"+trackingBranch).
176182
Run(&git.RunOpts{
177183
Dir: tmpBasePath,
178184
Stdout: &outbuf,

0 commit comments

Comments
 (0)