summaryrefslogtreecommitdiff
path: root/xmake/modules/devel/git/pull.lua
diff options
context:
space:
mode:
Diffstat (limited to 'xmake/modules/devel/git/pull.lua')
-rw-r--r--xmake/modules/devel/git/pull.lua24
1 files changed, 23 insertions, 1 deletions
diff --git a/xmake/modules/devel/git/pull.lua b/xmake/modules/devel/git/pull.lua
index 7eba74114..2320c51bd 100644
--- a/xmake/modules/devel/git/pull.lua
+++ b/xmake/modules/devel/git/pull.lua
@@ -21,6 +21,7 @@
-- imports
import("core.base.option")
import("lib.detect.find_tool")
+import("net.proxy")
-- pull remote commits
--
@@ -63,8 +64,29 @@ function main(opt)
oldir = os.cd(opt.repodir)
end
+ -- use proxy?
+ local envs
+ local proxy_conf = proxy.get()
+ if proxy_conf then
+ -- get proxy configuration from the current remote url
+ local remoteinfo = try { function() return os.iorunv(git.program, {"remote", "-v"}) end }
+ if remoteinfo then
+ for _, line in ipairs(remoteinfo:split('\n', {plain = true})) do
+ local splitinfo = line:split("%s+")
+ if #splitinfo > 1 and splitinfo[1] == (opt.remote or "origin") then
+ local url = splitinfo[2]
+ if url then
+ proxy_conf = proxy.get(url)
+ end
+ break
+ end
+ end
+ end
+ envs = {ALL_PROXY = proxy_conf}
+ end
+
-- pull it
- os.vrunv(git.program, argv)
+ os.vrunv(git.program, argv, {envs = envs})
-- leave repository directory
if oldir then