diff --git a/cmd/hook.go b/cmd/hook.go index 5c51b93ce..fa932087f 100644 --- a/cmd/hook.go +++ b/cmd/hook.go @@ -158,18 +158,6 @@ Gitea or set your environment appropriately.`, "") prID, _ := strconv.ParseInt(os.Getenv(models.ProtectedBranchPRID), 10, 64) isDeployKey, _ := strconv.ParseBool(os.Getenv(models.EnvIsDeployKey)) - //set environment for pre-receive hook script - os.Setenv(models.EnvRepoMaxFileSize, fmt.Sprint(setting.Repository.Upload.FileMaxSize)) - os.Setenv(models.EnvRepoMaxSize, fmt.Sprint(setting.Repository.RepoMaxSize)) - os.Setenv(models.EnvPushSizeCheckFlag, fmt.Sprint(setting.Repository.Upload.ShellFlag)) - env, _ := private.GetHookConfig(username, reponame) - if env != nil && len(env) > 0 { - repoSize := env[models.EnvRepoSize] - if repoSize != "" { - os.Setenv(models.EnvRepoSize, repoSize) - } - } - hookOptions := private.HookOptions{ UserID: userID, GitAlternativeObjectDirectories: os.Getenv(private.GitAlternativeObjectDirectories), diff --git a/cmd/serv.go b/cmd/serv.go index 7c2be5157..859639385 100644 --- a/cmd/serv.go +++ b/cmd/serv.go @@ -208,6 +208,19 @@ func runServ(c *cli.Context) error { os.Setenv(models.ProtectedBranchPRID, fmt.Sprintf("%d", 0)) os.Setenv(models.EnvIsDeployKey, fmt.Sprintf("%t", results.IsDeployKey)) os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID)) + //set environment for pre-receive hook script + os.Setenv(models.EnvRepoMaxFileSize, fmt.Sprint(setting.Repository.Upload.FileMaxSize)) + os.Setenv(models.EnvRepoMaxSize, fmt.Sprint(setting.Repository.RepoMaxSize)) + os.Setenv(models.EnvPushSizeCheckFlag, fmt.Sprint(setting.Repository.Upload.ShellFlag)) + env, _ := private.GetHookConfig(username, reponame) + fmt.Fprintln(os.Stderr, "Gitea:verb", verb) + if env != nil && len(env) > 0 { + repoSize := env[models.EnvRepoSize] + if repoSize != "" { + fmt.Fprintln(os.Stderr, "Gitea:repoSize", repoSize) + os.Setenv(models.EnvRepoSize, repoSize) + } + } //LFS token authentication if verb == lfsAuthenticateVerb {