Skip to content

Commit a722dd7

Browse files
authored
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 <[email protected]>
1 parent d17efaa commit a722dd7

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

cmd/serv.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ func runServ(c *cli.Context) error {
218218
os.Setenv(models.EnvPRID, fmt.Sprintf("%d", 0))
219219
os.Setenv(models.EnvIsDeployKey, fmt.Sprintf("%t", results.IsDeployKey))
220220
os.Setenv(models.EnvKeyID, fmt.Sprintf("%d", results.KeyID))
221+
os.Setenv(models.EnvAppURL, setting.AppURL)
221222

222223
//LFS token authentication
223224
if verb == lfsAuthenticateVerb {

models/helper_environment.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import (
88
"fmt"
99
"os"
1010
"strings"
11+
12+
"code.gitea.io/gitea/modules/setting"
1113
)
1214

1315
// env keys for git hooks need
@@ -23,6 +25,7 @@ const (
2325
EnvIsDeployKey = "GITEA_IS_DEPLOY_KEY"
2426
EnvPRID = "GITEA_PR_ID"
2527
EnvIsInternal = "GITEA_INTERNAL_PUSH"
28+
EnvAppURL = "GITEA_ROOT_URL"
2629
)
2730

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

routers/repo/http.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ func HTTP(ctx *context.Context) {
268268
models.EnvPusherName + "=" + authUser.Name,
269269
models.EnvPusherID + fmt.Sprintf("=%d", authUser.ID),
270270
models.EnvIsDeployKey + "=false",
271+
models.EnvAppURL + "=" + setting.AppURL,
271272
}
272273

273274
if !authUser.KeepEmailPrivate {

0 commit comments

Comments
 (0)