aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/deps.lua9
-rw-r--r--src/luarocks/fetch/git.lua17
2 files changed, 19 insertions, 7 deletions
diff --git a/src/luarocks/deps.lua b/src/luarocks/deps.lua
index 0e3265b5..f6c86d1c 100644
--- a/src/luarocks/deps.lua
+++ b/src/luarocks/deps.lua
@@ -159,6 +159,15 @@ function deps.compare_versions(a, b)
159 return deps.parse_version(a) > deps.parse_version(b) 159 return deps.parse_version(a) > deps.parse_version(b)
160end 160end
161 161
162--- Check if rockspec format version satisfies version requirement.
163-- @param rockspec table: The rockspec table.
164-- @param version string: required version.
165-- @return boolean: true if rockspec format matches version or is newer, false otherwise.
166function deps.format_is_at_least(rockspec, version)
167 local rockspec_format = rockspec.rockspec_format or "1.0"
168 return deps.parse_version(rockspec_format) >= deps.parse_version(version)
169end
170
162--- Consumes a constraint from a string, converting it to table format. 171--- Consumes a constraint from a string, converting it to table format.
163-- For example, a string ">= 1.0, > 2.0" is converted to a table in the 172-- For example, a string ">= 1.0, > 2.0" is converted to a table in the
164-- format {op = ">=", version={1,0}} and the rest, "> 2.0", is returned 173-- format {op = ">=", version={1,0}} and the rest, "> 2.0", is returned
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua
index 0847f735..ce41659b 100644
--- a/src/luarocks/fetch/git.lua
+++ b/src/luarocks/fetch/git.lua
@@ -110,15 +110,18 @@ function git.get_sources(rockspec, extract, dest_dir, depth)
110 end 110 end
111 end 111 end
112 112
113 command = {fs.Q(git_cmd), "submodule", "update", "--init", "--recursive"} 113 -- Fetching git submodules is supported only when rockspec format is >= 3.0.
114 if deps.format_is_at_least(rockspec, "3.0") then
115 command = {fs.Q(git_cmd), "submodule", "update", "--init", "--recursive"}
114 116
115 if git_supports_shallow_submodules(git_cmd) then 117 if git_supports_shallow_submodules(git_cmd) then
116 -- Fetch only the last commit of each submodule. 118 -- Fetch only the last commit of each submodule.
117 table.insert(command, 5, "--depth=1") 119 table.insert(command, 5, "--depth=1")
118 end 120 end
119 121
120 if not fs.execute(unpack(command)) then 122 if not fs.execute(unpack(command)) then
121 return nil, 'Failed to fetch submodules.' 123 return nil, 'Failed to fetch submodules.'
124 end
122 end 125 end
123 126
124 fs.delete(dir.path(store_dir, module, ".git")) 127 fs.delete(dir.path(store_dir, module, ".git"))