diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2015-12-29 20:35:10 -0200 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2015-12-29 20:35:10 -0200 |
| commit | faf7b4d2688a8d6027c062a9f0ebd7baee9ab5f5 (patch) | |
| tree | 6038f8748838ea3fb6a965a9c47af0c835afa64e | |
| parent | 84067c2d32bc4339fa6c4466bee87ee71c449b98 (diff) | |
| parent | 7a385f7c94aa655820b9955217bc58651dce6756 (diff) | |
| download | luarocks-faf7b4d2688a8d6027c062a9f0ebd7baee9ab5f5.tar.gz luarocks-faf7b4d2688a8d6027c062a9f0ebd7baee9ab5f5.tar.bz2 luarocks-faf7b4d2688a8d6027c062a9f0ebd7baee9ab5f5.zip | |
Merge pull request #473 from geoffleyland/add-git-ssh-support
Add git+ssh support to fetchers, including both kinds of git ssh url
| -rw-r--r-- | Makefile.setup.inc | 2 | ||||
| -rw-r--r-- | src/luarocks/fetch/git_ssh.lua | 32 |
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 \ | |||
| 16 | admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \ | 16 | admin_remove.lua fetch/hg.lua fetch/git_file.lua new_version.lua lint.lua \ |
| 17 | purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \ | 17 | purge.lua path.lua path_cmd.lua write_rockspec.lua doc.lua upload.lua \ |
| 18 | upload/api.lua upload/multipart.lua fetch/git_http.lua fetch/hg_http.lua \ | 18 | upload/api.lua upload/multipart.lua fetch/git_http.lua fetch/hg_http.lua \ |
| 19 | fetch/hg_https.lua fetch/hg_ssh.lua fetch/git_https.lua | 19 | fetch/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? | ||
| 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 | ||
