summaryrefslogtreecommitdiff
path: root/xmake/modules/devel/git
diff options
context:
space:
mode:
authorruki <[email protected]>2023-08-31 00:41:32 +0800
committerruki <[email protected]>2023-08-31 00:41:32 +0800
commit56c0b2a45c2c31d14a07dc684e2193447cd2e2e7 (patch)
tree5f81c4f5a1522ac23a7435e16a914ae55f0b1854 /xmake/modules/devel/git
parent39afcd4821aab51f2eaacdb163c87e9d55e2a4c7 (diff)
improve shallow submodules
Diffstat (limited to 'xmake/modules/devel/git')
-rw-r--r--xmake/modules/devel/git/clone.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/xmake/modules/devel/git/clone.lua b/xmake/modules/devel/git/clone.lua
index 469d36c2e..a1e7ca8eb 100644
--- a/xmake/modules/devel/git/clone.lua
+++ b/xmake/modules/devel/git/clone.lua
@@ -38,6 +38,20 @@ function can_clone_tag()
return can or false
end
+-- can clone with --shallow-submodules?
+-- @see https://github.com/xmake-io/xmake/issues/4151
+function can_shallow_submodules()
+ local can = _g.can_shallow_submodules
+ if can == nil then
+ local git = assert(find_tool("git", {version = true}), "git not found!")
+ if git.version and semver.compare(git.version, "2.9.0") >= 0 then
+ can = true
+ end
+ _g.can_shallow_submodules = can or false
+ end
+ return can or false
+end
+
-- clone url
--
-- @param url the git url
@@ -82,7 +96,7 @@ function main(url, opt)
if opt.recurse_submodules then
table.insert(argv, "--recurse-submodules")
end
- if opt.shallow_submodules then
+ if opt.shallow_submodules and can_shallow_submodules() then
table.insert(argv, "--shallow-submodules")
end