diff options
Diffstat (limited to 'src/luarocks/fetch/git_ssh.lua')
| -rw-r--r-- | src/luarocks/fetch/git_ssh.lua | 32 |
1 files changed, 32 insertions, 0 deletions
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? | ||
| 10 | local git_ssh = {} | ||
| 11 | |||
| 12 | local 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. | ||
| 21 | function 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, "--") | ||
| 30 | end | ||
| 31 | |||
| 32 | return git_ssh | ||
