From d9e3df1be0776eb82525ec76c0b450d1621ed2dc Mon Sep 17 00:00:00 2001 From: V1K1NGbg Date: Thu, 22 Aug 2024 17:49:04 -0300 Subject: Teal: convert luarocks.fetch.git_ssh --- src/luarocks/fetch/git_ssh.lua | 32 -------------------------------- src/luarocks/fetch/git_ssh.tl | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 32 deletions(-) delete mode 100644 src/luarocks/fetch/git_ssh.lua create mode 100644 src/luarocks/fetch/git_ssh.tl diff --git a/src/luarocks/fetch/git_ssh.lua b/src/luarocks/fetch/git_ssh.lua deleted file mode 100644 index 0c2c0750..00000000 --- a/src/luarocks/fetch/git_ssh.lua +++ /dev/null @@ -1,32 +0,0 @@ ---- Fetch back-end for retrieving sources from Git repositories --- that use ssh:// transport. For example, for fetching a repository --- that requires the following command line: --- `git clone ssh://git@example.com/path/foo.git --- you can use this in the rockspec: --- source = { url = "git+ssh://git@example.com/path/foo.git" } --- It also handles scp-style ssh urls: git@example.com:path/foo.git, --- but you have to prepend the "git+ssh://" and why not use the "newer" --- style anyway? -local git_ssh = {} - -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 git_ssh.get_sources(rockspec, extract, dest_dir) - rockspec.source.url = rockspec.source.url:gsub("^git.", "") - - -- Handle old-style scp-like git ssh urls - if rockspec.source.url:match("^ssh://[^/]+:[^%d]") then - rockspec.source.url = rockspec.source.url:gsub("^ssh://", "") - end - - return git.get_sources(rockspec, extract, dest_dir, "--") -end - -return git_ssh diff --git a/src/luarocks/fetch/git_ssh.tl b/src/luarocks/fetch/git_ssh.tl new file mode 100644 index 00000000..b5c30e3a --- /dev/null +++ b/src/luarocks/fetch/git_ssh.tl @@ -0,0 +1,35 @@ +--- Fetch back-end for retrieving sources from Git repositories +-- that use ssh:// transport. For example, for fetching a repository +-- that requires the following command line: +-- `git clone ssh://git@example.com/path/foo.git +-- you can use this in the rockspec: +-- source = { url = "git+ssh://git@example.com/path/foo.git" } +-- It also handles scp-style ssh urls: git@example.com:path/foo.git, +-- but you have to prepend the "git+ssh://" and why not use the "newer" +-- style anyway? +local record git_ssh +end + +local git = require("luarocks.fetch.git") + +local type Rockspec = require("luarocks.core.types.rockspec").Rockspec + +--- 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 git_ssh.get_sources(rockspec: Rockspec, extract: boolean, dest_dir?: string): string, string + rockspec.source.url = rockspec.source.url:gsub("^git.", "") + + -- Handle old-style scp-like git ssh urls + if rockspec.source.url:match("^ssh://[^/]+:[^%d]") then + rockspec.source.url = rockspec.source.url:gsub("^ssh://", "") + end + + return git.get_sources(rockspec, extract, dest_dir, "--") +end + +return git_ssh -- cgit v1.2.3-55-g6feb