mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-10 17:58:16 +00:00
perf(repo): fetch the initial commit instead of pushing it (#39628)
Creating a repository with an initial commit, via `auto_init` or a template with git content, pushed that commit through receive-pack and three server-side hooks that do nothing for this internal push except refresh server info. Fetching it into the bare repository instead makes such repository creation about 3.7x faster locally (median 790ms to 214ms). E2E tests that create initialized repositories get about 0.2-0.3s faster each. 1. Run `update-server-info` after template content generation, which the push's `post-receive` hook did before. 2. Remove the now unused `InternalPushingEnvironment` and `PushOptions.LocalRefName`.
This commit is contained in:
1 parent
a835fd78d1
commit
20ea3e204d
6 files changed
+25
-54
No files matched your search
+11
-4
@@ -18,8 +18,15 @@ import (
|
||||
// Ref: https://www.kernel.org/pub/software/scm/git/docs/git-gc.html
|
||||
func FetchRemoteTempCommit(ctx context.Context, repo, remoteRepo RepositoryFacade, commitID string) error {
|
||||
// since it is for temporary use, we don't need to update any ref or lock anything or maintain anything
|
||||
return gitcmd.NewCommand("fetch", "--no-tags", "--no-write-commit-graph", "--no-write-fetch-head", "--no-auto-maintenance").
|
||||
AddDynamicArguments(gitrepo.RepoLocalPath(remoteRepo)).
|
||||
AddDynamicArguments(commitID).
|
||||
WithRepo(repo).Run(ctx)
|
||||
return fetchRemoteCommand(remoteRepo, commitID).WithRepo(repo).Run(ctx)
|
||||
}
|
||||
|
||||
// FetchRemoteCommitUpdateRef fetches a commit from a remote repository and points refName at it
|
||||
func FetchRemoteCommitUpdateRef(ctx context.Context, repo, remoteRepo RepositoryFacade, commitish, refName string) error {
|
||||
return fetchRemoteCommand(remoteRepo, "+"+commitish+":"+refName).WithRepo(repo).RunWithStderr(ctx)
|
||||
}
|
||||
|
||||
func fetchRemoteCommand(remoteRepo RepositoryFacade, refspec string) *gitcmd.Command {
|
||||
return gitcmd.NewCommand("fetch", "--no-tags", "--no-write-commit-graph", "--no-write-fetch-head", "--no-auto-maintenance").
|
||||
AddDynamicArguments(gitrepo.RepoLocalPath(remoteRepo), refspec)
|
||||
}
|
||||
Reference in new issue
Block a user