diff options
Diffstat (limited to 'testing/gitano-test-tool.in')
-rw-r--r-- | testing/gitano-test-tool.in | 94 |
1 files changed, 47 insertions, 47 deletions
diff --git a/testing/gitano-test-tool.in b/testing/gitano-test-tool.in index 92e3e6c..88ccbc5 100644 --- a/testing/gitano-test-tool.in +++ b/testing/gitano-test-tool.in @@ -54,15 +54,15 @@ local function run_program(t) local function tprint (tbl, indent) if not indent then indent = 0 end for k, v in pairs(tbl) do - formatting = string.rep(" ", indent) .. k .. ": " - if type(v) == "table" then - print(formatting) - tprint(v, indent+1) - elseif type(v) == 'boolean' then - print(formatting .. tostring(v)) - else - print(formatting .. v) - end + formatting = string.rep(" ", indent) .. k .. ": " + if type(v) == "table" then + print(formatting) + tprint(v, indent+1) + elseif type(v) == 'boolean' then + print(formatting .. tostring(v)) + else + print(formatting .. v) + end end end tprint(t) @@ -100,16 +100,16 @@ local function load_auth(fname) line = line:gsub(" *$", "") line = line:gsub("^#.*", "") if line ~= "" then - local repopath, user, keyset, key = - line:match('^[^\\]+\\"([^"]+)\\" \\"([^"]+)\\" \\"([^"]+)\\""[^ ]+ (.+)$') - assert(repopath, line) - ret[#ret+1] = { - repopath = repopath, - user = user, - keyset = keyset, - key = key - } - ret[key] = ret[#ret] + local repopath, user, keyset, key = + line:match('^[^\\]+\\"([^"]+)\\" \\"([^"]+)\\" \\"([^"]+)\\""[^ ]+ (.+)$') + assert(repopath, line) + ret[#ret+1] = { + repopath = repopath, + user = user, + keyset = keyset, + key = key + } + ret[key] = ret[#ret] end line = fh:read("*l") end @@ -127,10 +127,10 @@ local function generate_exturl(user, key, repo) end return (extfmt):format(esc(user_home("testinstance")), esc("10.0.0.1 1234"), - "%S% " .. esc(repo), - esc(gitano.config.lib_bin_path() .. "/gitano-auth"), - esc(authline.repopath), - esc(authline.user), esc(authline.keyset)) + "%S% " .. esc(repo), + esc(gitano.config.lib_bin_path() .. "/gitano-auth"), + esc(authline.repopath), + esc(authline.user), esc(authline.keyset)) end local function generate_httpurl(user, key, repo) @@ -168,11 +168,11 @@ function cmd_createsshkey(username, keyname, optionaltype) local fh = io.open(sourcekey, "r") if not fh then run_program { - "ssh-keygen", "-q", - "-t", optionaltype, - "-C", username .. "-" .. optionaltype .. "@" .. keyname, - "-f", sourcekey, - "-N", "" } + "ssh-keygen", "-q", + "-t", optionaltype, + "-C", username .. "-" .. optionaltype .. "@" .. keyname, + "-f", sourcekey, + "-N", "" } fh = assert(io.open(sourcekey, "r")) end local ofh = assert(io.open(targetkey, "w")) @@ -229,13 +229,13 @@ $HTTP["url"] =~ ".*/gitano-command.cgi$" { ) auth.require = ( - "/" => ( - "method" => "basic", - "realm" => "Git Access", - "require" => "valid-user" - ) + "/" => ( + "method" => "basic", + "realm" => "Git Access", + "require" => "valid-user" + ) ) - + auth.backend = "htpasswd" auth.backend.htpasswd.userfile = %q } @@ -252,13 +252,13 @@ $HTTP["url"] =~ "^/git/.*$" { ) auth.require = ( - "/" => ( - "method" => "basic", - "realm" => "Git Access", - "require" => "valid-user" - ) + "/" => ( + "method" => "basic", + "realm" => "Git Access", + "require" => "valid-user" + ) ) - + auth.backend = "htpasswd" auth.backend.htpasswd.userfile = %q } @@ -278,11 +278,11 @@ $HTTP["url"] =~ "^/git/.*$" { port = port + 1 end if how == -1 then - unix_assert(how, why) + unix_assert(how, why) end if how ~= "exit" or why ~= 0 then io.stderr:write("Failed to spawn lighttpd server after 10 retries: " - .. how .. ":" .. tostring(why) .. "\n") + .. how .. ":" .. tostring(why) .. "\n") os.exit(1) end local fh = io.open(port_file, "w") @@ -377,16 +377,16 @@ function cmd_runcommand_http(user, key, ...) "testing/http-unwrap", gitano.config.lib_bin_path() .. "/gitano-command.cgi", env = { - HOME = user_home("testinstance"), - REMOTE_USER = authline.user, - REMOTE_ADDR = "10.0.0.1", - GITANO_ROOT = authline.repopath, + HOME = user_home("testinstance"), + REMOTE_USER = authline.user, + REMOTE_ADDR = "10.0.0.1", + GITANO_ROOT = authline.repopath, } } local elems = esc_quote_all_({...}) local function escape (str) str = string.gsub (str, "([^0-9a-zA-Z !'()*._~-])", -- locale independent - function (c) return string.format ("%%%02X", string.byte(c)) end) + function (c) return string.format ("%%%02X", string.byte(c)) end) str = string.gsub (str, " ", "+") return str end |