Set setting.AppURL as GITEA_ROOT_URL environment variable during pushes (#12752)

* Set setting.AppURL as GITEA_ROOT_URL environment variable during pushes

Fix #11738

Signed-off-by: Andrew Thornton <art27@cantab.net>
release/v1.15
zeripath 2020-09-07 04:53:42 +01:00 committed by GitHub
parent d17efaa114
commit a722dd72db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -218,6 +218,7 @@ func runServ(c *cli.Context) error {
os.Setenv(models.EnvPRID, fmt.Sprintf("%d", 0)) os.Setenv(models.EnvPRID, fmt.Sprintf("%d", 0))
os.Setenv(models.EnvIsDeployKey, fmt.Sprintf("%t", results.IsDeployKey)) os.Setenv(models.EnvIsDeployKey, fmt.Sprintf("%t", results.IsDeployKey))
os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID)) os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID))
os.Setenv(models.EnvAppURL, setting.AppURL)
//LFS token authentication //LFS token authentication
if verb == lfsAuthenticateVerb { if verb == lfsAuthenticateVerb {

View File

@ -8,6 +8,8 @@ import (
"fmt" "fmt"
"os" "os"
"strings" "strings"
"code.gitea.io/gitea/modules/setting"
) )
// env keys for git hooks need // env keys for git hooks need
@ -23,6 +25,7 @@ const (
EnvIsDeployKey = "GITEA_IS_DEPLOY_KEY" EnvIsDeployKey = "GITEA_IS_DEPLOY_KEY"
EnvPRID = "GITEA_PR_ID" EnvPRID = "GITEA_PR_ID"
EnvIsInternal = "GITEA_INTERNAL_PUSH" EnvIsInternal = "GITEA_INTERNAL_PUSH"
EnvAppURL = "GITEA_ROOT_URL"
) )
// InternalPushingEnvironment returns an os environment to switch off hooks on push // InternalPushingEnvironment returns an os environment to switch off hooks on push
@ -62,6 +65,7 @@ func FullPushingEnvironment(author, committer *User, repo *Repository, repoName
EnvPusherID+"="+fmt.Sprintf("%d", committer.ID), EnvPusherID+"="+fmt.Sprintf("%d", committer.ID),
EnvRepoID+"="+fmt.Sprintf("%d", repo.ID), EnvRepoID+"="+fmt.Sprintf("%d", repo.ID),
EnvPRID+"="+fmt.Sprintf("%d", prID), EnvPRID+"="+fmt.Sprintf("%d", prID),
EnvAppURL+"="+setting.AppURL,
"SSH_ORIGINAL_COMMAND=gitea-internal", "SSH_ORIGINAL_COMMAND=gitea-internal",
) )

View File

@ -268,6 +268,7 @@ func HTTP(ctx *context.Context) {
models.EnvPusherName + "=" + authUser.Name, models.EnvPusherName + "=" + authUser.Name,
models.EnvPusherID + fmt.Sprintf("=%d", authUser.ID), models.EnvPusherID + fmt.Sprintf("=%d", authUser.ID),
models.EnvIsDeployKey + "=false", models.EnvIsDeployKey + "=false",
models.EnvAppURL + "=" + setting.AppURL,
} }
if !authUser.KeepEmailPrivate { if !authUser.KeepEmailPrivate {