diff options
| author | Geoff Leyland <geoff.leyland@incremental.co.nz> | 2015-12-23 10:06:39 +1300 |
|---|---|---|
| committer | Geoff Leyland <geoff.leyland@incremental.co.nz> | 2015-12-23 10:06:39 +1300 |
| commit | 7a385f7c94aa655820b9955217bc58651dce6756 (patch) | |
| tree | ca640f6662f86a25d89e58bd1fe7e04a30ca3a25 /src | |
| parent | fe0156e6de2a3e257f80b23636792ecc7cd64a29 (diff) | |
| download | luarocks-7a385f7c94aa655820b9955217bc58651dce6756.tar.gz luarocks-7a385f7c94aa655820b9955217bc58651dce6756.tar.bz2 luarocks-7a385f7c94aa655820b9955217bc58651dce6756.zip | |
Add git+ssh support to fetchers, including both kinds of git ssh url
Diffstat (limited to 'src')
| -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 | ||
