mirror of
https://github.com/go-gitea/gitea.git
synced 2026-10-09 04:30:16 +09: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:
-13
@@ -169,10 +169,6 @@ func parseGitHookCommitRefLine(line string) (oldCommitID, newCommitID string, re
|
||||
}
|
||||
|
||||
func runHookPreReceive(ctx context.Context, c *cli.Command) error {
|
||||
if isInternal, _ := strconv.ParseBool(os.Getenv(repo_module.EnvIsInternal)); isInternal {
|
||||
return nil
|
||||
}
|
||||
|
||||
setup(ctx, c.Bool("debug"))
|
||||
|
||||
if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
|
||||
@@ -280,10 +276,6 @@ Gitea or set your environment appropriately.`, "")
|
||||
// runHookUpdate avoid to do heavy operations on update hook because it will be
|
||||
// invoked for every ref update which does not like pre-receive and post-receive
|
||||
func runHookUpdate(_ context.Context, c *cli.Command) error {
|
||||
if isInternal, _ := strconv.ParseBool(os.Getenv(repo_module.EnvIsInternal)); isInternal {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Update is empty and is kept only for backwards compatibility
|
||||
if len(os.Args) < 3 {
|
||||
return nil
|
||||
@@ -304,11 +296,6 @@ func runHookPostReceive(ctx context.Context, c *cli.Command) error {
|
||||
return fmt.Errorf("failed to call 'git update-server-info': %w", err)
|
||||
}
|
||||
|
||||
// Now if we're an internal don't do anything else
|
||||
if isInternal, _ := strconv.ParseBool(os.Getenv(repo_module.EnvIsInternal)); isInternal {
|
||||
return nil
|
||||
}
|
||||
|
||||
if len(os.Getenv("SSH_ORIGINAL_COMMAND")) == 0 {
|
||||
if setting.OnlyAllowPushIfGiteaEnvironmentSet {
|
||||
return fail(ctx, `Rejecting changes as Gitea environment not set.
|
||||
|
||||
Reference in New Issue
Block a user