summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Ipsum <richardipsum@fastmail.co.uk>2014-05-04 12:22:00 +0100
committerRichard Ipsum <richardipsum@fastmail.co.uk>2014-05-04 12:44:49 +0100
commit8a2d899b72f0adcd1c40f32c355d646cf72b3923 (patch)
tree0470c206d0ce8ce1b91daf17a7c875048f2ea0df
parent93f36f49ff6a92f307e1eacbdd91673734ca7dc5 (diff)
downloadgitano-8a2d899b72f0adcd1c40f32c355d646cf72b3923.tar.bz2
Move runcmd into util
-rw-r--r--lib/gitano/util.lua23
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/gitano/util.lua b/lib/gitano/util.lua
index 291c68d..5fc4ab1 100644
--- a/lib/gitano/util.lua
+++ b/lib/gitano/util.lua
@@ -15,6 +15,27 @@ local tconcat = table.concat
local check_password = scrypt.verify_password
+local function run_command(cmd, cmdline, parsed_cmdline, user,
+ config, env, repo)
+ log.debug("Welcome to " .. config.global.site_name)
+ log.debug("Running:")
+ for i = 1, #parsed_cmdline do
+ log.debug(" => " .. parsed_cmdline[i])
+ end
+ log.debug("")
+ log.debug("On behalf of " .. user .. " using key " .. env["GITANO_KEYTAG"])
+
+ local how, why = cmd.run(config, repo, parsed_cmdline, env)
+
+ if how ~= "exit" or why ~= 0 then
+ log.critical("Error running " .. parsed_cmdline[1] .. ": " .. how)
+ return why
+ else
+ log.syslog.info(cmdline, "completed successfully")
+ return 0
+ end
+end
+
local function hash_password(password)
-- For the moment we are using scrypt,
-- we may decide to use other hash functions in the future
@@ -502,4 +523,6 @@ return {
hash_password = hash_password,
check_password = check_password,
+
+ run_command = run_command,
}