diff options
| author | ruki <[email protected]> | 2025-12-03 00:36:40 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-12-03 00:36:40 +0800 |
| commit | 410c9ad1bef7982b47852491a3a9a7d870c090b5 (patch) | |
| tree | e581291a60219f1e23cccae94c3a38089b3e207e /xmake/modules/devel/git/push.lua | |
| parent | f9b12064a91aa52c55bbdac82d6ae2788fdf0d14 (diff) | |
fix proxy in git
Diffstat (limited to 'xmake/modules/devel/git/push.lua')
| -rw-r--r-- | xmake/modules/devel/git/push.lua | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/xmake/modules/devel/git/push.lua b/xmake/modules/devel/git/push.lua index 6609ca4a7..75272045f 100644 --- a/xmake/modules/devel/git/push.lua +++ b/xmake/modules/devel/git/push.lua @@ -20,7 +20,9 @@ -- imports import("core.base.option") +import("devel.git.remote") import("lib.detect.find_tool") +import("net.proxy") import("branch", {alias = "git_branch"}) -- push to given remote url and branch @@ -58,9 +60,27 @@ function main(url, opt) branch = branch .. ":" .. opt.remote_branch end table.insert(argv, branch) + + -- use proxy? + local envs + local proxy_conf = proxy.config() + if proxy_conf then + -- get proxy configuration from the remote url + -- if url is a remote name, get its URL; otherwise use url directly + local remote_url = url + if not url:find("://") and not url:find("@") then + -- looks like a remote name, get its URL + remote_url = remote.get_url({remote = url, repodir = opt.repodir}) + end + if remote_url then + proxy_conf = proxy.config(remote_url) + end + envs = {ALL_PROXY = proxy_conf} + end + if opt.verbose then - os.execv(git.program, argv, {curdir = opt.repodir}) + os.execv(git.program, argv, {envs = envs, curdir = opt.repodir}) else - os.vrunv(git.program, argv, {curdir = opt.repodir}) + os.vrunv(git.program, argv, {envs = envs, curdir = opt.repodir}) end end |
