aboutsummaryrefslogtreecommitdiff
path: root/src/luarocks/fetch/git.lua
diff options
context:
space:
mode:
authorThijs Schreijer <thijs@thijsschreijer.nl>2014-01-29 21:03:20 +0100
committerThijs Schreijer <thijs@thijsschreijer.nl>2014-01-29 21:03:20 +0100
commitd0aab1fa942409150e242cca18029debf547af9e (patch)
tree6d9b6c5190e17b400cf7f7ed08f2701e0fe29b75 /src/luarocks/fetch/git.lua
parent2078f83cc348c5b149fde1e4614ddc3e5b3d9b93 (diff)
downloadluarocks-d0aab1fa942409150e242cca18029debf547af9e.tar.gz
luarocks-d0aab1fa942409150e242cca18029debf547af9e.tar.bz2
luarocks-d0aab1fa942409150e242cca18029debf547af9e.zip
updated the `--branch` option to work through updating the rockspec `source.branch` field
Additionally a fix for the `git` module, to use command quoting
Diffstat (limited to '')
-rw-r--r--src/luarocks/fetch/git.lua6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua
index 1845363f..2bba4cdc 100644
--- a/src/luarocks/fetch/git.lua
+++ b/src/luarocks/fetch/git.lua
@@ -12,7 +12,7 @@ local util = require("luarocks.util")
12-- given tag. 12-- given tag.
13-- @return boolean: Whether Git can clone by tag. 13-- @return boolean: Whether Git can clone by tag.
14local function git_can_clone_by_tag(git_cmd) 14local function git_can_clone_by_tag(git_cmd)
15 local version_string = io.popen(git_cmd..' --version'):read() 15 local version_string = io.popen(fs.Q(git_cmd)..' --version'):read()
16 local major, minor, tiny = version_string:match('(%d-)%.(%d+)%.?(%d*)') 16 local major, minor, tiny = version_string:match('(%d-)%.(%d+)%.?(%d*)')
17 major, minor, tiny = tonumber(major), tonumber(minor), tonumber(tiny) or 0 17 major, minor, tiny = tonumber(major), tonumber(minor), tonumber(tiny) or 0
18 local value = major > 1 or (major == 1 and (minor > 7 or (minor == 7 and tiny >= 10))) 18 local value = major > 1 or (major == 1 and (minor > 7 or (minor == 7 and tiny >= 10)))
@@ -51,7 +51,7 @@ function get_sources(rockspec, extract, dest_dir, depth)
51 local ok, err = fs.change_dir(store_dir) 51 local ok, err = fs.change_dir(store_dir)
52 if not ok then return nil, err end 52 if not ok then return nil, err end
53 53
54 local command = {git_cmd, "clone", depth or "--depth=1", rockspec.source.url, module} 54 local command = {fs.Q(git_cmd), "clone", depth or "--depth=1", rockspec.source.url, module}
55 local tag_or_branch = rockspec.source.tag or rockspec.source.branch 55 local tag_or_branch = rockspec.source.tag or rockspec.source.branch
56 -- If the tag or branch is explicitly set to "master" in the rockspec, then 56 -- If the tag or branch is explicitly set to "master" in the rockspec, then
57 -- we can avoid passing it to Git since it's the default. 57 -- we can avoid passing it to Git since it's the default.
@@ -69,7 +69,7 @@ function get_sources(rockspec, extract, dest_dir, depth)
69 local ok, err = fs.change_dir(module) 69 local ok, err = fs.change_dir(module)
70 if not ok then return nil, err end 70 if not ok then return nil, err end
71 if tag_or_branch and not git_can_clone_by_tag() then 71 if tag_or_branch and not git_can_clone_by_tag() then
72 local checkout_command = {git_cmd, "checkout", tag_or_branch} 72 local checkout_command = {fs.Q(git_cmd), "checkout", tag_or_branch}
73 if not fs.execute(unpack(checkout_command)) then 73 if not fs.execute(unpack(checkout_command)) then
74 return nil, 'Failed to check out the "' .. tag_or_branch ..'" tag or branch.' 74 return nil, 'Failed to check out the "' .. tag_or_branch ..'" tag or branch.'
75 end 75 end