diff options
author | Thijs Schreijer <thijs@thijsschreijer.nl> | 2014-01-29 12:44:57 -0800 |
---|---|---|
committer | Thijs Schreijer <thijs@thijsschreijer.nl> | 2014-01-29 12:44:57 -0800 |
commit | 93f69e68225c4520f844a55f91648a73889bffb3 (patch) | |
tree | 770475900de3548274e1e119d41bec001195d9f6 | |
parent | 097d81a8b1f81c3688b7f22db5654b73fa1251fe (diff) | |
parent | fd1d38a2d170deb9c7ffd0289a9bb97efac6f6ba (diff) | |
download | luarocks-93f69e68225c4520f844a55f91648a73889bffb3.tar.gz luarocks-93f69e68225c4520f844a55f91648a73889bffb3.tar.bz2 luarocks-93f69e68225c4520f844a55f91648a73889bffb3.zip |
Merge pull request #226 from Tieske/branch_option
add --branch=<branchname> option
-rw-r--r-- | src/luarocks/build.lua | 4 | ||||
-rw-r--r-- | src/luarocks/command_line.lua | 7 | ||||
-rw-r--r-- | src/luarocks/fetch.lua | 3 | ||||
-rw-r--r-- | src/luarocks/fetch/git.lua | 6 | ||||
-rw-r--r-- | src/luarocks/make.lua | 4 |
5 files changed, 21 insertions, 3 deletions
diff --git a/src/luarocks/build.lua b/src/luarocks/build.lua index 72b5649e..0e58e2e5 100644 --- a/src/luarocks/build.lua +++ b/src/luarocks/build.lua | |||
@@ -32,6 +32,10 @@ or the name of a rock to be fetched from a repository. | |||
32 | be made permanent by setting keep_other_versions=true | 32 | be made permanent by setting keep_other_versions=true |
33 | in the configuration file. | 33 | in the configuration file. |
34 | 34 | ||
35 | --branch=<name> Override the `source.branch` field in the loaded | ||
36 | rockspec. Allows to specify a different branch to | ||
37 | fetch. Particularly for SCM rocks. | ||
38 | |||
35 | ]]..util.deps_mode_help() | 39 | ]]..util.deps_mode_help() |
36 | 40 | ||
37 | --- Install files to a given location. | 41 | --- Install files to a given location. |
diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 19d04290..f9fba300 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua | |||
@@ -113,6 +113,13 @@ function run_command(...) | |||
113 | die("Invalid entry for --deps-mode.") | 113 | die("Invalid entry for --deps-mode.") |
114 | end | 114 | end |
115 | 115 | ||
116 | if flags["branch"] then | ||
117 | if flags["branch"] == true or flags["branch"] == "" then | ||
118 | die("Argument error: use --branch=<branch-name>") | ||
119 | end | ||
120 | cfg.branch = flags["branch"] | ||
121 | end | ||
122 | |||
116 | if flags["tree"] then | 123 | if flags["tree"] then |
117 | if flags["tree"] == true or flags["tree"] == "" then | 124 | if flags["tree"] == true or flags["tree"] == "" then |
118 | die("Argument error: use --tree=<path>") | 125 | die("Argument error: use --tree=<path>") |
diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index 7960acb4..8e08e7ad 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua | |||
@@ -148,6 +148,9 @@ function load_local_rockspec(filename, quick) | |||
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 cfg.branch and (type(rockspec.source) == "table") then | ||
152 | rockspec.source.branch = cfg.branch | ||
153 | end | ||
151 | local globals = err | 154 | local globals = err |
152 | 155 | ||
153 | local ok, err = true, nil | 156 | local ok, err = true, nil |
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 |
diff --git a/src/luarocks/make.lua b/src/luarocks/make.lua index 3999e39f..af7e68e6 100644 --- a/src/luarocks/make.lua +++ b/src/luarocks/make.lua | |||
@@ -36,6 +36,10 @@ To install rocks, you'll normally want to use the "install" and | |||
36 | be made permanent by setting keep_other_versions=true | 36 | be made permanent by setting keep_other_versions=true |
37 | in the configuration file. | 37 | in the configuration file. |
38 | 38 | ||
39 | --branch=<name> Override the `source.branch` field in the loaded | ||
40 | rockspec. Allows to specify a different branch to | ||
41 | fetch. Particularly for SCM rocks. | ||
42 | |||
39 | ]] | 43 | ]] |
40 | 44 | ||
41 | --- Driver function for "make" command. | 45 | --- Driver function for "make" command. |