diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2014-05-16 18:03:13 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2014-05-16 18:03:13 +0100 |
commit | f010726f585dc15f71673ca4be749757e9ed10cb (patch) | |
tree | 5a85de10bfdc398392e3176df2382172b956d942 /lib/gitano/util.lua | |
parent | 93f36f49ff6a92f307e1eacbdd91673734ca7dc5 (diff) | |
parent | 800ec03542c7bc09afbddce9a2b01f94d615fce9 (diff) | |
download | gitano-f010726f585dc15f71673ca4be749757e9ed10cb.tar.gz |
Merge remote-tracking branch 'ri/richardipsum/refactor'
Diffstat (limited to 'lib/gitano/util.lua')
-rw-r--r-- | lib/gitano/util.lua | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/gitano/util.lua b/lib/gitano/util.lua index 291c68d..ab8730a 100644 --- a/lib/gitano/util.lua +++ b/lib/gitano/util.lua @@ -15,6 +15,28 @@ 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) + log.critical("Unable to continue") + 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 +524,6 @@ return { hash_password = hash_password, check_password = check_password, + + run_command = run_command, } |