Skip to content

Commit

Permalink
Set setting.AppURL as GITEA_ROOT_URL environment variable during push…
Browse files Browse the repository at this point in the history
…es (go-gitea#12752)

* Set setting.AppURL as GITEA_ROOT_URL environment variable during pushes

Fix go-gitea#11738

Signed-off-by: Andrew Thornton <art27@cantab.net>
  • Loading branch information
zeripath authored Sep 7, 2020
1 parent d17efaa commit a722dd7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/serv.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ func runServ(c *cli.Context) error {
os.Setenv(models.EnvPRID, fmt.Sprintf("%d", 0))
os.Setenv(models.EnvIsDeployKey, fmt.Sprintf("%t", results.IsDeployKey))
os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID))
os.Setenv(models.EnvAppURL, setting.AppURL)

//LFS token authentication
if verb == lfsAuthenticateVerb {
Expand Down
4 changes: 4 additions & 0 deletions models/helper_environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"fmt"
"os"
"strings"

"code.gitea.io/gitea/modules/setting"
)

// env keys for git hooks need
Expand All @@ -23,6 +25,7 @@ const (
EnvIsDeployKey = "GITEA_IS_DEPLOY_KEY"
EnvPRID = "GITEA_PR_ID"
EnvIsInternal = "GITEA_INTERNAL_PUSH"
EnvAppURL = "GITEA_ROOT_URL"
)

// InternalPushingEnvironment returns an os environment to switch off hooks on push
Expand Down Expand Up @@ -62,6 +65,7 @@ func FullPushingEnvironment(author, committer *User, repo *Repository, repoName
EnvPusherID+"="+fmt.Sprintf("%d", committer.ID),
EnvRepoID+"="+fmt.Sprintf("%d", repo.ID),
EnvPRID+"="+fmt.Sprintf("%d", prID),
EnvAppURL+"="+setting.AppURL,
"SSH_ORIGINAL_COMMAND=gitea-internal",
)

Expand Down
1 change: 1 addition & 0 deletions routers/repo/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ func HTTP(ctx *context.Context) {
models.EnvPusherName + "=" + authUser.Name,
models.EnvPusherID + fmt.Sprintf("=%d", authUser.ID),
models.EnvIsDeployKey + "=false",
models.EnvAppURL + "=" + setting.AppURL,
}

if !authUser.KeepEmailPrivate {
Expand Down

0 comments on commit a722dd7

Please sign in to comment.