diff options
| author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2014-01-29 21:03:20 +0100 |
|---|---|---|
| committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2014-01-29 21:03:20 +0100 |
| commit | d0aab1fa942409150e242cca18029debf547af9e (patch) | |
| tree | 6d9b6c5190e17b400cf7f7ed08f2701e0fe29b75 /src | |
| parent | 2078f83cc348c5b149fde1e4614ddc3e5b3d9b93 (diff) | |
| download | luarocks-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 'src')
| -rw-r--r-- | src/luarocks/fetch.lua | 8 | ||||
| -rw-r--r-- | src/luarocks/fetch/git.lua | 6 |
2 files changed, 6 insertions, 8 deletions
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index e0525dde..8e08e7ad 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua | |||
| @@ -144,14 +144,12 @@ end | |||
| 144 | function load_local_rockspec(filename, quick) | 144 | function load_local_rockspec(filename, quick) |
| 145 | assert(type(filename) == "string") | 145 | assert(type(filename) == "string") |
| 146 | filename = fs.absolute_name(filename) | 146 | filename = fs.absolute_name(filename) |
| 147 | local rockspec, err = persist.load_into_table(filename, {BRANCH = cfg.branch}) -- temp add BRANCH | 147 | local rockspec, err = persist.load_into_table(filename) |
| 148 | if not rockspec then | 148 | if not rockspec then |
| 149 | return nil, "Could not load rockspec file "..filename.." ("..err..")" | 149 | return nil, "Could not load rockspec file "..filename.." ("..err..")" |
| 150 | end | 150 | end |
| 151 | if rockspec.BRANCH ~= cfg.branch then | 151 | if cfg.branch and (type(rockspec.source) == "table") then |
| 152 | return nil, "Invalid rockspec, BRANCH constant was illegally modified by rockspec" | 152 | rockspec.source.branch = cfg.branch |
| 153 | else | ||
| 154 | rockspec.BRANCH = nil -- remove temporary added field | ||
| 155 | end | 153 | end |
| 156 | local globals = err | 154 | local globals = err |
| 157 | 155 | ||
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. |
| 14 | local function git_can_clone_by_tag(git_cmd) | 14 | local 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 |
