aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.setup.inc2
-rw-r--r--src/luarocks/fetch/git_ssh.lua32
2 files changed, 33 insertions, 1 deletions
diff --git a/Makefile.setup.inc b/Makefile.setup.inc
index c228e78c..0a049bc4 100644
--- a/Makefile.setup.inc
+++ b/Makefile.setup.inc
@@ -16,5 +16,5 @@ help.lua util.lua index.lua cache.lua refresh_cache.lua loader.lua \
16admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \ 16admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \
17purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \ 17purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \
18upload/api.lua upload/multipart.lua fetch/git_http.lua fetch/hg_http.lua \ 18upload/api.lua upload/multipart.lua fetch/git_http.lua fetch/hg_http.lua \
19fetch/hg_https.lua fetch/hg_ssh.lua fetch/git_https.lua 19fetch/hg_https.lua fetch/hg_ssh.lua fetch/git_https.lua fetch/git_ssh.lua
20 20
diff --git a/src/luarocks/fetch/git_ssh.lua b/src/luarocks/fetch/git_ssh.lua
new file mode 100644
index 00000000..0c2c0750
--- /dev/null
+++ b/src/luarocks/fetch/git_ssh.lua
@@ -0,0 +1,32 @@
1--- Fetch back-end for retrieving sources from Git repositories
2-- that use ssh:// transport. For example, for fetching a repository
3-- that requires the following command line:
4-- `git clone ssh://git@example.com/path/foo.git
5-- you can use this in the rockspec:
6-- source = { url = "git+ssh://git@example.com/path/foo.git" }
7-- It also handles scp-style ssh urls: git@example.com:path/foo.git,
8-- but you have to prepend the "git+ssh://" and why not use the "newer"
9-- style anyway?
10local git_ssh = {}
11
12local git = require("luarocks.fetch.git")
13
14--- Fetch sources for building a rock from a local Git repository.
15-- @param rockspec table: The rockspec table
16-- @param extract boolean: Unused in this module (required for API purposes.)
17-- @param dest_dir string or nil: If set, will extract to the given directory.
18-- @return (string, string) or (nil, string): The absolute pathname of
19-- the fetched source tarball and the temporary directory created to
20-- store it; or nil and an error message.
21function git_ssh.get_sources(rockspec, extract, dest_dir)
22 rockspec.source.url = rockspec.source.url:gsub("^git.", "")
23
24 -- Handle old-style scp-like git ssh urls
25 if rockspec.source.url:match("^ssh://[^/]+:[^%d]") then
26 rockspec.source.url = rockspec.source.url:gsub("^ssh://", "")
27 end
28
29 return git.get_sources(rockspec, extract, dest_dir, "--")
30end
31
32return git_ssh