diff options
author | Hisham Muhammad <hisham@gobolinux.org> | 2014-01-15 01:58:04 -0200 |
---|---|---|
committer | Hisham Muhammad <hisham@gobolinux.org> | 2014-01-15 01:58:04 -0200 |
commit | 304987887671d67181846b9d321cd91d54840ed8 (patch) | |
tree | e93215c556352d4e55f43c5ac23560bd819e552b | |
parent | c358d9be5149fedbdb056045d3d4bb9821b0ad70 (diff) | |
download | luarocks-304987887671d67181846b9d321cd91d54840ed8.tar.gz luarocks-304987887671d67181846b9d321cd91d54840ed8.tar.bz2 luarocks-304987887671d67181846b9d321cd91d54840ed8.zip |
Add git+http fetch module to be used in case of "git clone http://..." URLs.
-rw-r--r-- | src/luarocks/fetch/git.lua | 4 | ||||
-rw-r--r-- | src/luarocks/fetch/git_http.lua | 17 |
2 files changed, 19 insertions, 2 deletions
diff --git a/src/luarocks/fetch/git.lua b/src/luarocks/fetch/git.lua index 90d4eea8..1845363f 100644 --- a/src/luarocks/fetch/git.lua +++ b/src/luarocks/fetch/git.lua | |||
@@ -27,7 +27,7 @@ end | |||
27 | -- @return (string, string) or (nil, string): The absolute pathname of | 27 | -- @return (string, string) or (nil, string): The absolute pathname of |
28 | -- the fetched source tarball and the temporary directory created to | 28 | -- the fetched source tarball and the temporary directory created to |
29 | -- store it; or nil and an error message. | 29 | -- store it; or nil and an error message. |
30 | function get_sources(rockspec, extract, dest_dir) | 30 | function get_sources(rockspec, extract, dest_dir, depth) |
31 | assert(type(rockspec) == "table") | 31 | assert(type(rockspec) == "table") |
32 | assert(type(dest_dir) == "string" or not dest_dir) | 32 | assert(type(dest_dir) == "string" or not dest_dir) |
33 | 33 | ||
@@ -51,7 +51,7 @@ function get_sources(rockspec, extract, dest_dir) | |||
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=1", rockspec.source.url, module} | 54 | local command = {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. |
diff --git a/src/luarocks/fetch/git_http.lua b/src/luarocks/fetch/git_http.lua new file mode 100644 index 00000000..19de70ab --- /dev/null +++ b/src/luarocks/fetch/git_http.lua | |||
@@ -0,0 +1,17 @@ | |||
1 | |||
2 | --- Fetch back-end for retrieving sources from local Git repositories. | ||
3 | module("luarocks.fetch.git_http", package.seeall) | ||
4 | |||
5 | local git = require("luarocks.fetch.git") | ||
6 | |||
7 | --- Fetch sources for building a rock from a local Git repository. | ||
8 | -- @param rockspec table: The rockspec table | ||
9 | -- @param extract boolean: Unused in this module (required for API purposes.) | ||
10 | -- @param dest_dir string or nil: If set, will extract to the given directory. | ||
11 | -- @return (string, string) or (nil, string): The absolute pathname of | ||
12 | -- the fetched source tarball and the temporary directory created to | ||
13 | -- store it; or nil and an error message. | ||
14 | function get_sources(rockspec, extract, dest_dir) | ||
15 | rockspec.source.url = rockspec.source.url:gsub("^git.", "") | ||
16 | return git.get_sources(rockspec, extract, dest_dir, "--") | ||
17 | end | ||