diff options
| author | V1K1NGbg <victor@ilchev.com> | 2024-08-22 17:49:05 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2024-10-21 13:30:51 -0300 |
| commit | 5a3fab9fca93c6f586b9bd34954a1bf3e9d2ea4f (patch) | |
| tree | 627e1d546662beb42b3924e7fc72445a70f8a5c3 /src | |
| parent | fe692ffc7971337e3fcafba6b679a1e8ea16264d (diff) | |
| download | luarocks-5a3fab9fca93c6f586b9bd34954a1bf3e9d2ea4f.tar.gz luarocks-5a3fab9fca93c6f586b9bd34954a1bf3e9d2ea4f.tar.bz2 luarocks-5a3fab9fca93c6f586b9bd34954a1bf3e9d2ea4f.zip | |
Teal: convert luarocks.fetch.hg
Diffstat (limited to 'src')
| -rw-r--r-- | src/luarocks/fetch/hg.tl (renamed from src/luarocks/fetch/hg.lua) | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/luarocks/fetch/hg.lua b/src/luarocks/fetch/hg.tl index 0ef0f5e4..3f94cee1 100644 --- a/src/luarocks/fetch/hg.lua +++ b/src/luarocks/fetch/hg.tl | |||
| @@ -1,13 +1,14 @@ | |||
| 1 | 1 | ||
| 2 | --- Fetch back-end for retrieving sources from HG. | 2 | --- Fetch back-end for retrieving sources from HG. |
| 3 | local hg = {} | 3 | local record hg |
| 4 | 4 | end | |
| 5 | local unpack = unpack or table.unpack | ||
| 6 | 5 | ||
| 7 | local fs = require("luarocks.fs") | 6 | local fs = require("luarocks.fs") |
| 8 | local dir = require("luarocks.dir") | 7 | local dir = require("luarocks.dir") |
| 9 | local util = require("luarocks.util") | 8 | local util = require("luarocks.util") |
| 10 | 9 | ||
| 10 | local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | ||
| 11 | |||
| 11 | --- Download sources for building a rock, using hg. | 12 | --- Download sources for building a rock, using hg. |
| 12 | -- @param rockspec table: The rockspec table | 13 | -- @param rockspec table: The rockspec table |
| 13 | -- @param extract boolean: Unused in this module (required for API purposes.) | 14 | -- @param extract boolean: Unused in this module (required for API purposes.) |
| @@ -15,13 +16,11 @@ local util = require("luarocks.util") | |||
| 15 | -- @return (string, string) or (nil, string): The absolute pathname of | 16 | -- @return (string, string) or (nil, string): The absolute pathname of |
| 16 | -- the fetched source tarball and the temporary directory created to | 17 | -- the fetched source tarball and the temporary directory created to |
| 17 | -- store it; or nil and an error message. | 18 | -- store it; or nil and an error message. |
| 18 | function hg.get_sources(rockspec, extract, dest_dir) | 19 | function hg.get_sources(rockspec: Rockspec, extract: boolean, dest_dir?: string): string, string |
| 19 | assert(rockspec:type() == "rockspec") | ||
| 20 | assert(type(dest_dir) == "string" or not dest_dir) | ||
| 21 | 20 | ||
| 22 | local hg_cmd = rockspec.variables.HG | 21 | local hg_cmd = rockspec.variables.HG |
| 23 | local ok, err_msg = fs.is_tool_available(hg_cmd, "Mercurial") | 22 | local ok_available, err_msg = fs.is_tool_available(hg_cmd, "Mercurial") |
| 24 | if not ok then | 23 | if not ok_available then |
| 25 | return nil, err_msg | 24 | return nil, err_msg |
| 26 | end | 25 | end |
| 27 | 26 | ||
| @@ -36,7 +35,7 @@ function hg.get_sources(rockspec, extract, dest_dir) | |||
| 36 | if tag_or_branch then | 35 | if tag_or_branch then |
| 37 | command = {hg_cmd, "clone", "--rev", tag_or_branch, url, module} | 36 | command = {hg_cmd, "clone", "--rev", tag_or_branch, url, module} |
| 38 | end | 37 | end |
| 39 | local store_dir | 38 | local store_dir: string |
| 40 | if not dest_dir then | 39 | if not dest_dir then |
| 41 | store_dir = fs.make_temp_dir(name_version) | 40 | store_dir = fs.make_temp_dir(name_version) |
| 42 | if not store_dir then | 41 | if not store_dir then |
| @@ -48,7 +47,7 @@ function hg.get_sources(rockspec, extract, dest_dir) | |||
| 48 | end | 47 | end |
| 49 | local ok, err = fs.change_dir(store_dir) | 48 | local ok, err = fs.change_dir(store_dir) |
| 50 | if not ok then return nil, err end | 49 | if not ok then return nil, err end |
| 51 | if not fs.execute(unpack(command)) then | 50 | if not fs.execute(table.unpack(command)) then |
| 52 | return nil, "Failed cloning hg repository." | 51 | return nil, "Failed cloning hg repository." |
| 53 | end | 52 | end |
| 54 | ok, err = fs.change_dir(module) | 53 | ok, err = fs.change_dir(module) |
