aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/luarocks/fetch/svn.tl (renamed from src/luarocks/fetch/svn.lua)23
1 files changed, 11 insertions, 12 deletions
diff --git a/src/luarocks/fetch/svn.lua b/src/luarocks/fetch/svn.tl
index b6618afc..4d738d74 100644
--- a/src/luarocks/fetch/svn.lua
+++ b/src/luarocks/fetch/svn.tl
@@ -1,13 +1,14 @@
1 1
2--- Fetch back-end for retrieving sources from Subversion. 2--- Fetch back-end for retrieving sources from Subversion.
3local svn = {} 3local record svn
4 4end
5local unpack = unpack or table.unpack
6 5
7local fs = require("luarocks.fs") 6local fs = require("luarocks.fs")
8local dir = require("luarocks.dir") 7local dir = require("luarocks.dir")
9local util = require("luarocks.util") 8local util = require("luarocks.util")
10 9
10local type Rockspec = require("luarocks.core.types.rockspec").Rockspec
11
11--- Download sources for building a rock, using Subversion. 12--- Download sources for building a rock, using Subversion.
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,9 +16,7 @@ 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.
18function svn.get_sources(rockspec, extract, dest_dir) 19function svn.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 svn_cmd = rockspec.variables.SVN 21 local svn_cmd = rockspec.variables.SVN
23 local ok, err_msg = fs.is_tool_available(svn_cmd, "Subversion") 22 local ok, err_msg = fs.is_tool_available(svn_cmd, "Subversion")
@@ -33,7 +32,7 @@ function svn.get_sources(rockspec, extract, dest_dir)
33 table.insert(command, 5, "-r") 32 table.insert(command, 5, "-r")
34 table.insert(command, 6, rockspec.source.tag) 33 table.insert(command, 6, rockspec.source.tag)
35 end 34 end
36 local store_dir 35 local store_dir: string
37 if not dest_dir then 36 if not dest_dir then
38 store_dir = fs.make_temp_dir(name_version) 37 store_dir = fs.make_temp_dir(name_version)
39 if not store_dir then 38 if not store_dir then
@@ -43,13 +42,13 @@ function svn.get_sources(rockspec, extract, dest_dir)
43 else 42 else
44 store_dir = dest_dir 43 store_dir = dest_dir
45 end 44 end
46 local ok, err = fs.change_dir(store_dir) 45 local okchange, err = fs.change_dir(store_dir)
47 if not ok then return nil, err end 46 if not okchange then return nil, err end
48 if not fs.execute(unpack(command)) then 47 if not fs.execute(table.unpack(command)) then
49 return nil, "Failed fetching files from Subversion." 48 return nil, "Failed fetching files from Subversion."
50 end 49 end
51 ok, err = fs.change_dir(module) 50 okchange, err = fs.change_dir(module)
52 if not ok then return nil, err end 51 if not okchange then return nil, err end
53 for _, d in ipairs(fs.find(".")) do 52 for _, d in ipairs(fs.find(".")) do
54 if dir.base_name(d) == ".svn" then 53 if dir.base_name(d) == ".svn" then
55 fs.delete(dir.path(store_dir, module, d)) 54 fs.delete(dir.path(store_dir, module, d))