aboutsummaryrefslogtreecommitdiff
path: root/services
diff options
context:
space:
mode:
authorGusted2023-02-11 01:39:50 +0100
committerGitHub2023-02-11 08:39:50 +0800
commit1cb8d14bf71e0b8637c9eaa10808b4fd05139f45 (patch)
tree13d3b089cd0a944bd2a50529282fd645d9610637 /services
parentaffdd40296960a08a4223330ccbd1fb88c96ea1a (diff)
Use proxy for pull mirror (#22771)
- Use the proxy (if one is specified) for pull mirrors syncs. - Pulled the code from https://github.com/go-gitea/gitea/blob/c2774d9e80d9a436d9c2044960369c4db227e3a0/modules/git/repo.go#L164-L170 Downstream issue: https://codeberg.org/forgejo/forgejo/issues/302 --------- Co-authored-by: Lauris BH <lauris@nix.lv>
Diffstat (limited to 'services')
-rw-r--r--services/mirror/mirror_pull.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/services/mirror/mirror_pull.go b/services/mirror/mirror_pull.go
index 7dee90352..126d2bf35 100644
--- a/services/mirror/mirror_pull.go
+++ b/services/mirror/mirror_pull.go
@@ -18,6 +18,7 @@ import (
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/notification"
"code.gitea.io/gitea/modules/process"
+ "code.gitea.io/gitea/modules/proxy"
repo_module "code.gitea.io/gitea/modules/repository"
"code.gitea.io/gitea/modules/setting"
"code.gitea.io/gitea/modules/timeutil"
@@ -215,6 +216,8 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
return nil, false
}
+ envs := proxy.EnvWithProxy(remoteURL.URL)
+
stdoutBuilder := strings.Builder{}
stderrBuilder := strings.Builder{}
if err := cmd.
@@ -222,6 +225,7 @@ func runSync(ctx context.Context, m *repo_model.Mirror) ([]*mirrorSyncResult, bo
Run(&git.RunOpts{
Timeout: timeout,
Dir: repoPath,
+ Env: envs,
Stdout: &stdoutBuilder,
Stderr: &stderrBuilder,
}); err != nil {