diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-01-02 17:17:19 +0000 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2017-01-02 17:18:09 +0000 |
commit | 79fcfa572b7834f7768fa2fedb954059e47791f3 (patch) | |
tree | 7ea09a2f322885765b53bc04de07ca480a97b45c /bin | |
parent | 8ddd848fe17864e59b4c293974cb2c50e3639082 (diff) | |
download | gitano-79fcfa572b7834f7768fa2fedb954059e47791f3.tar.gz |
cleanups: Whitespace and indentation and untabify
This is a massive unpleasant commit which does whitespace cleanup
and fixes indentation (including untabifying). Hopefully we won't
need to do this ever again, if we keep an eye on commits.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/gitano-auth.in | 4 | ||||
-rw-r--r-- | bin/gitano-command.cgi.in | 14 | ||||
-rw-r--r-- | bin/gitano-post-receive-hook.in | 11 | ||||
-rw-r--r-- | bin/gitano-pre-receive-hook.in | 5 | ||||
-rw-r--r-- | bin/gitano-setup.in | 86 | ||||
-rw-r--r-- | bin/gitano-update-hook.in | 102 |
6 files changed, 110 insertions, 112 deletions
diff --git a/bin/gitano-auth.in b/bin/gitano-auth.in index d82f941..d8c21b3 100644 --- a/bin/gitano-auth.in +++ b/bin/gitano-auth.in @@ -41,11 +41,11 @@ local authorized, cmd, parsed_cmdline, config, env, repo = if authorized then local exit, quiet = gitano.util.run_command(cmd, cmdline, parsed_cmdline, - user, config, env, repo) + user, config, env, repo) if exit ~= 0 then if not quiet then - gitano.log.critical(gitano.i18n.expand("ERROR_COMMAND_FAILED")) + gitano.log.critical(gitano.i18n.expand("ERROR_COMMAND_FAILED")) end luxio._exit(exit) end diff --git a/bin/gitano-command.cgi.in b/bin/gitano-command.cgi.in index 9280f32..cb42d1e 100644 --- a/bin/gitano-command.cgi.in +++ b/bin/gitano-command.cgi.in @@ -23,11 +23,11 @@ local sio = require "luxio.simple" local stdout = sio.stdout function url_decode(str) - str = string.gsub (str, "+", " ") - str = string.gsub (str, "%%(%x%x)", - function(h) return string.char(tonumber(h,16)) end) - str = string.gsub (str, "\r\n", "\n") - return str + str = string.gsub(str, "+", " ") + str = string.gsub(str, "%%(%x%x)", + function(h) return string.char(tonumber(h,16)) end) + str = string.gsub(str, "\r\n", "\n") + return str end if os.getenv("QUERY_STRING") then @@ -63,10 +63,10 @@ if os.getenv("QUERY_STRING") then if authorized then local exit = gitano.util.run_command(cmd, cmdline, parsed_cmdline, - user, config, env, repo) + user, config, env, repo) stdout:write("Status: " .. (exit == 0 and "200 OK" or "400 Bad request") - .. "\r\n\r\n") + .. "\r\n\r\n") stdout:write(gitano.log.get_buffered_output() or "") else stdout:write("Status: 403 Forbidden\r\n\r\n") diff --git a/bin/gitano-post-receive-hook.in b/bin/gitano-post-receive-hook.in index b9de48b..8e352c7 100644 --- a/bin/gitano-post-receive-hook.in +++ b/bin/gitano-post-receive-hook.in @@ -78,7 +78,7 @@ if not repo then gitano.log.critical(" * " .. (tostring(msg))) gitano.log.fatal(gitano.i18n.expand("ERROR_CANNOT_CONTINUE")) end - + if repo.is_nascent then gitano.log.fatal(gitano.i18n.expand("ERROR_REPO_IS_NASCENT", {name=repo.name})) end @@ -88,8 +88,7 @@ end -- emails, ensuring that new rules are applied, etc) local updates = {} -for oldsha, newsha, refname in - (sio.stdin:read("*a")):gmatch("([^ ]+) ([^ ]+) ([^\n]+)\n?") do +for oldsha, newsha, refname in (sio.stdin:read("*a")):gmatch("([^ ]+) ([^ ]+) ([^\n]+)\n?") do gitano.log.ddebug("post-receive:", oldsha, newsha, refname) updates[refname] = {oldsha, newsha, oldsha=oldsha, newsha=newsha} end @@ -135,9 +134,9 @@ if repo.name == "gitano-admin" and updates[admin_repo.HEAD] then gitano.log.syslog.info(msg) local proc = sp.spawn({ - gitano.config.lib_bin_path() .. "/gitano-update-ssh", - gitano.config.repo_path() - }) + gitano.config.lib_bin_path() .. "/gitano-update-ssh", + gitano.config.repo_path() + }) local how, why = proc:wait() if how ~= "exit" or why ~= 0 then gitano.log.crit(gitano.i18n.expand("ERROR_UPDATE_SSH_NOT_WORK")) diff --git a/bin/gitano-pre-receive-hook.in b/bin/gitano-pre-receive-hook.in index 694894e..89fafea 100644 --- a/bin/gitano-pre-receive-hook.in +++ b/bin/gitano-pre-receive-hook.in @@ -78,7 +78,7 @@ if not repo then gitano.log.critical(" * " .. (tostring(msg))) gitano.log.fatal(gitano.i18n.expand("ERROR_CANNOT_CONTINUE")) end - + if repo.is_nascent then gitano.log.fatal(gitano.i18n.expand("ERROR_REPO_IS_NASCENT", {name=repo.name})) end @@ -91,8 +91,7 @@ end -- you. local updates = {} -for oldsha, newsha, refname in - (sio.stdin:read("*a")):gmatch("([^ ]+) ([^ ]+) ([^\n]+)") do +for oldsha, newsha, refname in (sio.stdin:read("*a")):gmatch("([^ ]+) ([^ ]+) ([^\n]+)") do gitano.log.ddebug("pre-receive:", oldsha, newsha, refname) updates[refname] = {oldsha, newsha, oldsha=oldsha, newsha=newsha} end diff --git a/bin/gitano-setup.in b/bin/gitano-setup.in index bb3e86b..1d57a8b 100644 --- a/bin/gitano-setup.in +++ b/bin/gitano-setup.in @@ -23,12 +23,12 @@ local clod = require "clod" local possible_answers = {...} -if possible_answers[1] == "--help" or - possible_answers[1] == "-h" or - possible_answers[1] == "--usage" then - sio.stderr:write(gitano.i18n.expand("SETUP_USAGE")) - return 1 -end +if (possible_answers[1] == "--help" + or possible_answers[1] == "-h" + or possible_answers[1] == "--usage") then + sio.stderr:write(gitano.i18n.expand("SETUP_USAGE")) + return 1 +end local conf = clod.parse("") @@ -38,7 +38,7 @@ gitano.log.bump_level(gitano.log.level.CHAT) for i = #possible_answers, 1, -1 do gitano.log.debug(gitano.i18n.expand("SETUP_DEBUG_PARSING_ANSWERS", { file=possible_answers[1] })) local one_conf = assert(clod.parse(assert(io.open(possible_answers[1], "r")):read "*a", - "@" .. possible_answers[1])) + "@" .. possible_answers[1])) gitano.log.debug(gitano.i18n.expand("SETUP_DEBUG_COMBINE_ANSWERS")) for k,v in one_conf:each() do gitano.log.ddebug(tostring(k) .. " = " .. tostring(v)) @@ -56,21 +56,21 @@ local ok, msg = pcall(function() local s = require 'supple' local ok, a, b, c = s.host.run("return ...", "test", 12, 'hello', true) if not ok then - gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_UNABLE")) - os.exit(1) + gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_UNABLE")) + os.exit(1) end if a ~= 12 or b ~= "hello" or c ~= true then - gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_VALUES")) - os.exit(1) + gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_VALUES")) + os.exit(1) end local ok, v = s.host.run("local a = ...\nreturn a.banana", "test", {banana=14}) if not ok then - gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_UNABLE")) - os.exit(1) + gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_UNABLE")) + os.exit(1) end if v ~= 14 then - gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_BIDIRECTIONAL")) - os.exit(1) + gitano.log.chat(gitano.i18n.expand("SETUP_CHECK_SUPPLE_BIDIRECTIONAL")) + os.exit(1) end end) @@ -89,17 +89,17 @@ end function ask_for(key, prompt, default) local cur_value = conf.settings[key] or default gitano.log.ddebug("ask_for(", tostring(key), ", ", tostring(prompt), ", ", - tostring(default), ") [", tostring(cur_value), " ]") + tostring(default), ") [", tostring(cur_value), " ]") if not conf.settings["setup.batch"] then local default_str = (cur_value == nil) and "" or " [" .. tostring(cur_value) .. "]" sio.stdout:write((prompt or key) .. default_str .. ": ") local new_value = sio.stdin:read("*l") if new_value and new_value ~= "" then - cur_value = new_value + cur_value = new_value end end gitano.log.info(gitano.i18n.expand("SETUP_SETTING_IS", - { key = key, value = tostring(cur_value)})) + { key = key, value = tostring(cur_value)})) conf.settings[key] = cur_value return cur_value end @@ -146,10 +146,10 @@ end gitano.log.chat(gitano.i18n.expand("SETUP_STEP_1")) validate_path(ask_for("paths.home", gitano.i18n.expand("SETUP_PATHS_HOME_INFO"), - os.getenv "HOME")) + os.getenv "HOME")) ask_for("paths.ssh", gitano.i18n.expand("SETUP_PATHS_SSH_INFO"), - get("paths.home") .. "/.ssh") + get("paths.home") .. "/.ssh") local pubkey_path if look_for_path(get("paths.ssh")) then @@ -157,33 +157,33 @@ if look_for_path(get("paths.ssh")) then for _, ktype in ipairs { "rsa", "ecdsa" } do local pk = get("paths.ssh") .. "/id_" .. ktype .. ".pub" if file_exists(pk) then - pubkey_path = pk - break + pubkey_path = pk + break end end end assert(file_exists(ask_for("paths.bypasskey", gitano.i18n.expand("SETUP_PATHS_BYPASSKEY_INFO"), - pubkey_path)), + pubkey_path)), gitano.i18n.expand("SETUP_PATHS_BYPASSKEY_NOT_FOUND")) assert(file_exists(ask_for("paths.pubkey", gitano.i18n.expand("SETUP_PATHS_PUBKEY_INFO"), - get("paths.home") .. "/admin.pub")), + get("paths.home") .. "/admin.pub")), gitano.i18n.expand("SETUP_PATHS_PUBKEY_NOT_FOUND")) ask_for("paths.repos", gitano.i18n.expand("SETUP_PATHS_REPOS_INFO"), - get("paths.home") .. "/repos") + get("paths.home") .. "/repos") validate_name(ask_for("admin.username", gitano.i18n.expand("SETUP_ADMIN_USERNAME_INFO"), - "admin")) + "admin")) ask_for("admin.realname", gitano.i18n.expand("SETUP_ADMIN_REALNAME_INFO"), - "Administrator") + "Administrator") ask_for("admin.email", gitano.i18n.expand("SETUP_ADMIN_EMAIL_INFO"), - "admin@administrator.local") + "admin@administrator.local") validate_name(ask_for("admin.keyname", gitano.i18n.expand("SETUP_ADMIN_KEYNAME_INFO"), - "default")) + "default")) ask_for("site.name", gitano.i18n.expand("SETUP_SITE_NAME_INFO"), "a random Gitano instance") ask_for("log.prefix", gitano.i18n.expand("SETUP_LOG_PREFIX_INFO"), "gitano") @@ -210,17 +210,17 @@ local function acquire(dir, base, path) gitano.log.ddebug("Acquire skeleton in:", path) for ent in dir:iterate() do if not (ent == "." or ent == "..") then - local entpath = path .. "/" .. ent - local treeent = base .. ent - if look_for_path(entpath) then - local subdir = assert(sio.opendir(entpath)) - acquire(subdir, treeent .. "/", entpath) - subdir:close() - else - local fh = io.open(entpath, "r") - completely_flat[treeent] = fh:read "*a" - fh:close() - end + local entpath = path .. "/" .. ent + local treeent = base .. ent + if look_for_path(entpath) then + local subdir = assert(sio.opendir(entpath)) + acquire(subdir, treeent .. "/", entpath) + subdir:close() + else + local fh = io.open(entpath, "r") + completely_flat[treeent] = fh:read "*a" + fh:close() + end end end end @@ -266,8 +266,8 @@ gitano.config.repo_path(get "paths.repos") gitano.log.info(gitano.i18n.expand("SETUP_PREPARE_REPO")) -local raw_repo = assert(gall.repository.create(get("paths.repos") .. - "/gitano-admin.git")) +local raw_repo = assert(gall.repository.create(get("paths.repos") .. + "/gitano-admin.git")) gitano.log.info(gitano.i18n.expand("SETUP_PREPARE_FLAT_TREE")) for k, v in pairs(completely_flat) do @@ -294,7 +294,7 @@ local commit_obj = assert(gall.commit.create(raw_repo, commit_data)) gitano.log.info(gitano.i18n.expand("SETUP_PREPARE_MASTER")) assert(raw_repo:update_ref("refs/heads/master", commit_obj.sha, - "Create initial master ref")) + "Create initial master ref")) gitano.log.info(gitano.i18n.expand("SETUP_CHECK_ADMIN_REPO")) diff --git a/bin/gitano-update-hook.in b/bin/gitano-update-hook.in index 87aa110..1beb9a2 100644 --- a/bin/gitano-update-hook.in +++ b/bin/gitano-update-hook.in @@ -82,7 +82,7 @@ if not repo then gitano.log.critical(" * " .. (tostring(msg))) gitano.log.fatal(gitano.i18n.expand("ERROR_CANNOT_CONTINUE")) end - + if repo.is_nascent then gitano.log.fatal(gitano.i18n.expand("ERROR_REPO_IS_NASCENT", {name=repo.name})) end @@ -135,14 +135,14 @@ local function do_expensive_populate_context(context) else local thing = repo.git:get(oldsha) while thing.type == "tag" do - thing = thing.content.object + thing = thing.content.object end if thing.type == "commit" then - oldtree = thing.content.tree.content + oldtree = thing.content.tree.content else - oldtree = repo.git:get(gall.tree.empty_sha).content - gitano.log.warn(gitano.i18n.expand("ODD_OLD_OBJECT_NOT_COMMIT_OR_TAG", - {sha=oldsha})) + oldtree = repo.git:get(gall.tree.empty_sha).content + gitano.log.warn(gitano.i18n.expand("ODD_OLD_OBJECT_NOT_COMMIT_OR_TAG", + {sha=oldsha})) end end @@ -151,14 +151,14 @@ local function do_expensive_populate_context(context) else local thing = repo.git:get(newsha) while thing.type == "tag" do - thing = thing.content.object + thing = thing.content.object end if thing.type == "commit" then - newtree = thing.content.tree.content + newtree = thing.content.tree.content else - newtree = repo.git:get(gall.tree.empty_sha).content - gitano.log.warn(gitano.i18n.expand("ODD_NEW_OBJECT_NOT_COMMIT_OR_TAG", - {sha=newsha})) + newtree = repo.git:get(gall.tree.empty_sha).content + gitano.log.warn(gitano.i18n.expand("ODD_NEW_OBJECT_NOT_COMMIT_OR_TAG", + {sha=newsha})) end end @@ -167,7 +167,7 @@ local function do_expensive_populate_context(context) local function set_list(tag, entries) -- Make the set for direct string tests for i = 1, #entries do - entries[entries[i]] = true + entries[entries[i]] = true end context[tag] = entries end @@ -176,7 +176,7 @@ local function do_expensive_populate_context(context) local flat_tree = gall.tree.flatten(tree) local names = {} for fn in pairs(flat_tree) do - names[#names+1] = fn + names[#names+1] = fn end set_list(tag, names) end @@ -194,22 +194,22 @@ local function do_expensive_populate_context(context) local fname = details.filename targets[#targets+1] = fname if details.action == "A" then - added[#added+1] = fname + added[#added+1] = fname end if details.action == "C" and details.score == "100" then - added[#added+1] = fname + added[#added+1] = fname end if details.action == "D" then - deleted[#deleted+1] = fname + deleted[#deleted+1] = fname end if details.action == "M" or - ((details.action == "R" or details.action == "C") and - (tonumber(details.score) < 100)) then - modified[#modified+1] = fname + ((details.action == "R" or details.action == "C") and + (tonumber(details.score) < 100)) then + modified[#modified+1] = fname end if details.action == "R" then - renamed[#renamed+1] = details.src_name - renamedto[#renamedto+1] = fname + renamed[#renamed+1] = details.src_name + renamedto[#renamedto+1] = fname end context["treediff/kind/" .. fname] = details.endkind @@ -226,18 +226,18 @@ end local function defer_generation(key) context[key] = function(ctx) - -- This populates quite a bit, so we do this - -- test in case someone else got hold of this - -- beforehand and manages to cross the streams - if type(ctx[key]) == "function" then - gitano.log.chat(gitano.i18n.expand("GENERATING_TREEDELTAS", - {key=key})) - do_expensive_populate_context(ctx) - gitano.log.chat(gitano.i18n.expand("GENERATED_TREEDELTAS")) - end - -- And return what we were meant to be - return ctx[key] - end + -- This populates quite a bit, so we do this + -- test in case someone else got hold of this + -- beforehand and manages to cross the streams + if type(ctx[key]) == "function" then + gitano.log.chat(gitano.i18n.expand("GENERATING_TREEDELTAS", + {key=key})) + do_expensive_populate_context(ctx) + gitano.log.chat(gitano.i18n.expand("GENERATED_TREEDELTAS")) + end + -- And return what we were meant to be + return ctx[key] + end end defer_generation "start_tree" @@ -256,21 +256,21 @@ local function populate(sha, pfx) else local obj = repo.git:get(sha) if not obj then - context[pfx.."type"] = "unknown" + context[pfx.."type"] = "unknown" else - context[pfx.."type"] = obj.type - if obj.type == 'tag' then - obj = obj.content.object - if not obj then - context[pfx.."taggedtype"] = "unknown" - else - context[pfx.."taggedtype"] = obj.type - context[pfx.."taggedsha"] = obj.sha - end - end - if obj.content and obj.content.signature and obj.content.signature ~= "" then - context[pfx.."signed"] = "yes" - end + context[pfx.."type"] = obj.type + if obj.type == 'tag' then + obj = obj.content.object + if not obj then + context[pfx.."taggedtype"] = "unknown" + else + context[pfx.."taggedtype"] = obj.type + context[pfx.."taggedsha"] = obj.sha + end + end + if obj.content and obj.content.signature and obj.content.signature ~= "" then + context[pfx.."signed"] = "yes" + end end end end @@ -288,7 +288,7 @@ end if action ~= "allow" then gitano.log.critical(gitano.i18n.expand("ERROR_RULES_REFUSED_UPDATE", - {reason=reason})) + {reason=reason})) gitano.log.fatal(gitano.i18n.expand("ERROR_RULESET_DENIED_ACTION")) end @@ -317,7 +317,7 @@ if repo:uses_hook("update") then email = (config.users[username] or {}).email_address or "", } local ok, msg = gitano.supple.run_hook("update", repo, info, - refname, oldsha, newsha) + refname, oldsha, newsha) if not ok then gitano.log.fatal(msg or gitano.i18n.expand("ERROR_NO_ERROR_FOUND")) end @@ -325,10 +325,10 @@ if repo:uses_hook("update") then end gitano.log.info(gitano.i18n.expand("ALLOWING_UPDATE", - {ref=refname, old=oldsha, new=newsha})) + {ref=refname, old=oldsha, new=newsha})) gitano.log.syslog.info("Allowing ref", action, "of", refname, - "( was", oldsha, "is now", newsha, ")") + "( was", oldsha, "is now", newsha, ")") gitano.log.syslog.close() |