diff options
| author | ruki <[email protected]> | 2020-06-23 22:37:44 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2020-06-23 22:37:44 +0800 |
| commit | c18d15eb89116a0f3ce96bd56f3ccf861849f6ec (patch) | |
| tree | 52b63db3274349f9a41872414208c7c30058cfd7 /xmake/modules/devel/git | |
| parent | 53df324acd9c7432336a5894ceef578daa1ce38d (diff) | |
| parent | 18bded45c229f5580c13fc8b4afc5edb6f18819a (diff) | |
Merge pull request #857 from xmake-io/toolchain
Improve toolchain to support host and cross toolchains at same time
Diffstat (limited to 'xmake/modules/devel/git')
| -rw-r--r-- | xmake/modules/devel/git/clone.lua | 10 | ||||
| -rw-r--r-- | xmake/modules/devel/git/ls_remote.lua | 10 | ||||
| -rw-r--r-- | xmake/modules/devel/git/pull.lua | 24 |
3 files changed, 41 insertions, 3 deletions
diff --git a/xmake/modules/devel/git/clone.lua b/xmake/modules/devel/git/clone.lua index 4285b392d..ef3aa769b 100644 --- a/xmake/modules/devel/git/clone.lua +++ b/xmake/modules/devel/git/clone.lua @@ -21,6 +21,7 @@ -- imports import("core.base.option") import("lib.detect.find_tool") +import("net.proxy") -- clone url -- @@ -75,6 +76,13 @@ function main(url, opt) table.insert(argv, path.translate(opt.outputdir)) end + -- use proxy? + local envs + local proxy_conf = proxy.get(url) + if proxy_conf then + envs = {ALL_PROXY = proxy_conf} + end + -- clone it - os.vrunv(git.program, argv) + os.vrunv(git.program, argv, {envs = envs}) end diff --git a/xmake/modules/devel/git/ls_remote.lua b/xmake/modules/devel/git/ls_remote.lua index a52e0d68d..1775567db 100644 --- a/xmake/modules/devel/git/ls_remote.lua +++ b/xmake/modules/devel/git/ls_remote.lua @@ -21,6 +21,7 @@ -- imports import("core.base.option") import("lib.detect.find_tool") +import("net.proxy") -- ls_remote to given branch, tag or commit -- @@ -55,8 +56,15 @@ function main(reftype, url) print("%s %s", git.program, os.args(argv)) end + -- use proxy? + local envs + local proxy_conf = proxy.get(url) + if proxy_conf then + envs = {ALL_PROXY = proxy_conf} + end + -- get refs - local data = os.iorunv(git.program, argv) + local data = os.iorunv(git.program, argv, {envs = envs}) -- get commmits and tags local refs = {} 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 |
