From 304987887671d67181846b9d321cd91d54840ed8 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Wed, 15 Jan 2014 01:58:04 -0200 Subject: Add git+http fetch module to be used in case of "git clone http://..." URLs. --- src/luarocks/fetch/git.lua | 4 ++-- src/luarocks/fetch/git_http.lua | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) create mode 100644 src/luarocks/fetch/git_http.lua 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 -- @return (string, string) or (nil, string): The absolute pathname of -- the fetched source tarball and the temporary directory created to -- store it; or nil and an error message. -function get_sources(rockspec, extract, dest_dir) +function get_sources(rockspec, extract, dest_dir, depth) assert(type(rockspec) == "table") assert(type(dest_dir) == "string" or not dest_dir) @@ -51,7 +51,7 @@ function get_sources(rockspec, extract, dest_dir) local ok, err = fs.change_dir(store_dir) if not ok then return nil, err end - local command = {git_cmd, "clone", "--depth=1", rockspec.source.url, module} + local command = {git_cmd, "clone", depth or "--depth=1", rockspec.source.url, module} local tag_or_branch = rockspec.source.tag or rockspec.source.branch -- If the tag or branch is explicitly set to "master" in the rockspec, then -- 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 @@ + +--- Fetch back-end for retrieving sources from local Git repositories. +module("luarocks.fetch.git_http", package.seeall) + +local git = require("luarocks.fetch.git") + +--- Fetch sources for building a rock from a local Git repository. +-- @param rockspec table: The rockspec table +-- @param extract boolean: Unused in this module (required for API purposes.) +-- @param dest_dir string or nil: If set, will extract to the given directory. +-- @return (string, string) or (nil, string): The absolute pathname of +-- the fetched source tarball and the temporary directory created to +-- store it; or nil and an error message. +function get_sources(rockspec, extract, dest_dir) + rockspec.source.url = rockspec.source.url:gsub("^git.", "") + return git.get_sources(rockspec, extract, dest_dir, "--") +end -- cgit v1.2.3-55-g6feb