summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2021-11-25 10:22:08 +0800
committerruki <[email protected]>2021-11-25 10:22:08 +0800
commitb7588b6bc50d511154b18bad81c3a659ce3e9437 (patch)
tree0f811deb1bf2beee123ed97f81d14d6f5278a865
parenta3e6076aff9fa5b3ad43ac2a3b1de88c61319a7d (diff)
add mirror for repo
-rw-r--r--xmake/modules/private/action/require/impl/repository.lua7
-rw-r--r--xmake/plugins/repo/main.lua7
2 files changed, 10 insertions, 4 deletions
diff --git a/xmake/modules/private/action/require/impl/repository.lua b/xmake/modules/private/action/require/impl/repository.lua
index 8bd92aa04..189fad594 100644
--- a/xmake/modules/private/action/require/impl/repository.lua
+++ b/xmake/modules/private/action/require/impl/repository.lua
@@ -24,6 +24,7 @@ import("core.base.global")
import("core.project.config")
import("core.package.repository")
import("devel.git")
+import("net.proxy")
-- get package directory from the locked repository
function _get_packagedir_from_locked_repo(packagename, locked_repo)
@@ -55,7 +56,8 @@ function _get_packagedir_from_locked_repo(packagename, locked_repo)
git.clone(repo_global:directory(), {verbose = option.get("verbose"), outputdir = repodir_local})
lastcommit = repo_global:commit()
elseif global.get("network") ~= "private" then
- git.clone(locked_repo.url, {verbose = option.get("verbose"), branch = locked_repo.branch, outputdir = repodir_local})
+ local remoteurl = proxy.mirror(locked_repo.url) or locked_repo.url
+ git.clone(remoteurl, {verbose = option.get("verbose"), branch = locked_repo.branch, outputdir = repodir_local})
else
wprint("we cannot lock repository(%s) in private network mode!", locked_repo.url)
return
@@ -73,7 +75,8 @@ function _get_packagedir_from_locked_repo(packagename, locked_repo)
if not ok then
if global.get("network") ~= "private" then
-- pull the latest commit
- git.pull({verbose = option.get("verbose"), remote = locked_repo.url, branch = locked_repo.branch, repodir = repodir_local})
+ local remoteurl = proxy.mirror(locked_repo.url) or locked_repo.url
+ git.pull({verbose = option.get("verbose"), remote = remoteurl, branch = locked_repo.branch, repodir = repodir_local})
-- re-checkout to the given commit
ok = try {function () git.checkout(locked_repo.commit, {verbose = option.get("verbose"), repodir = repodir_local}); return true end}
else
diff --git a/xmake/plugins/repo/main.lua b/xmake/plugins/repo/main.lua
index a4ec01b90..4baa1f540 100644
--- a/xmake/plugins/repo/main.lua
+++ b/xmake/plugins/repo/main.lua
@@ -25,6 +25,7 @@ import("core.project.project")
import("core.platform.platform")
import("core.package.repository")
import("devel.git")
+import("net.proxy")
import("private.async.runjobs")
import("private.action.require.impl.environment")
@@ -45,7 +46,8 @@ function _add(name, url, branch, is_global)
-- clone repository
if not os.isdir(url) then
- git.clone(url, {verbose = option.get("verbose"), branch = branch or "master", outputdir = repodir})
+ local remoteurl = proxy.mirror(url) or url
+ git.clone(remoteurl, {verbose = option.get("verbose"), branch = branch or "master", outputdir = repodir})
end
-- trace
@@ -117,7 +119,8 @@ function _update()
vprint("cloning repository(%s): %s to %s ..", repo:name(), repo:url(), repodir)
-- clone it
- git.clone(repo:url(), {verbose = option.get("verbose"), branch = repo:branch() or "master", outputdir = repodir})
+ local remoteurl = proxy.mirror(repo:url()) or repo:url()
+ git.clone(remoteurl, {verbose = option.get("verbose"), branch = repo:branch() or "master", outputdir = repodir})
-- mark as updated
io.save(path.join(repodir, "updated"), {})