From ae2d3a684540bddc910fb68d47659cd87af0916d Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Thu, 16 Feb 2012 15:58:16 -0200 Subject: Add git_file pseudoprotocol for handling local Git repos, using "git+file:///path/to/repo.git". Closes #59. --- src/luarocks/fetch.lua | 2 +- src/luarocks/fetch/git_file.lua | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 src/luarocks/fetch/git_file.lua diff --git a/src/luarocks/fetch.lua b/src/luarocks/fetch.lua index bdb448c7..b835b20e 100644 --- a/src/luarocks/fetch.lua +++ b/src/luarocks/fetch.lua @@ -302,7 +302,7 @@ function fetch_sources(rockspec, extract, dest_dir) if protocol == "http" or protocol == "https" or protocol == "ftp" or protocol == "file" then proto = require("luarocks.fetch") else - ok, proto = pcall(require, "luarocks.fetch."..protocol) + ok, proto = pcall(require, "luarocks.fetch."..protocol:gsub("[+-]", "_")) if not ok then return nil, "Unknown protocol "..protocol end diff --git a/src/luarocks/fetch/git_file.lua b/src/luarocks/fetch/git_file.lua new file mode 100644 index 00000000..1b18d0fa --- /dev/null +++ b/src/luarocks/fetch/git_file.lua @@ -0,0 +1,17 @@ + +--- Fetch back-end for retrieving sources from local Git repositories. +module("luarocks.fetch.git_file", 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.file://", "") + return git.get_sources(rockspec, extract, dest_dir) +end -- cgit v1.2.3-55-g6feb