diff options
| author | mpeterv <mpeterval@gmail.com> | 2015-06-25 14:14:16 +0300 |
|---|---|---|
| committer | mpeterv <mpeterval@gmail.com> | 2015-06-26 15:43:46 +0300 |
| commit | 1e9edc66b768ad9e78401cf51931967430de1f7b (patch) | |
| tree | 679630f4c9f9fa71e53d67b2cfc6d76d8fd22383 /src | |
| parent | d8a72ee125aa0acfa8d43b910572edfcc61cd434 (diff) | |
| download | luarocks-1e9edc66b768ad9e78401cf51931967430de1f7b.tar.gz luarocks-1e9edc66b768ad9e78401cf51931967430de1f7b.tar.bz2 luarocks-1e9edc66b768ad9e78401cf51931967430de1f7b.zip | |
Check that rockspec format is at least 3.0 before fetching submodules
For utility, add deps.format_is_at_least(rockspec, version) function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/deps.lua | 9 | ||||
| -rw-r--r-- | src/luarocks/fetch/git.lua | 17 |
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) |
| 160 | end | 160 | end |
| 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. | ||
| 166 | function 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) | ||
| 169 | end | ||
| 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")) |
