summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-09-01 10:28:19 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-09-01 10:28:19 +0100
commit22290b4a4d93ed7c36a84786551c65b9d36d336c (patch)
tree414156f315e468d42e11255c559983f2c31e681d
parentf12458c7194b61d66621fe1731c6bc21d54d18c4 (diff)
downloadgitano-22290b4a4d93ed7c36a84786551c65b9d36d336c.tar.gz
SUPPLE: Supply an actor table in the global namespace of each hook, containing info about the user
-rw-r--r--bin/gitano-post-receive-hook.in9
-rw-r--r--bin/gitano-pre-receive-hook.in9
-rw-r--r--bin/gitano-update-hook.in9
-rw-r--r--lib/gitano/supple.lua11
4 files changed, 32 insertions, 6 deletions
diff --git a/bin/gitano-post-receive-hook.in b/bin/gitano-post-receive-hook.in
index e56a778..04ba587 100644
--- a/bin/gitano-post-receive-hook.in
+++ b/bin/gitano-post-receive-hook.in
@@ -131,7 +131,14 @@ if repo:uses_hook("post-receive") then
gitano.log.debug("Configuring for post-receive hook")
gitano.actions.set_supple_globals("post-receive")
gitano.log.info("Running repository post-receive hook")
- local ok, msg = gitano.supple.run_hook("post-receive", repo, updates)
+ local info = {
+ username = username,
+ keytag = keytag,
+ source = source,
+ realname = (config.users[username] or {}).real_name or "",
+ email = (config.users[username] or {}).email_address or "",
+ }
+ local ok, msg = gitano.supple.run_hook("post-receive", repo, info, updates)
if not ok then
gitano.log.crit(msg or "No reason given, but errored somehow.")
end
diff --git a/bin/gitano-pre-receive-hook.in b/bin/gitano-pre-receive-hook.in
index 1477401..b8f5339 100644
--- a/bin/gitano-pre-receive-hook.in
+++ b/bin/gitano-pre-receive-hook.in
@@ -91,7 +91,14 @@ if repo:uses_hook("pre-receive") then
gitano.log.debug("Configuring for pre-receive hook")
gitano.actions.set_supple_globals("pre-receive")
gitano.log.info("Running repository pre-receive hook")
- local ok, msg = gitano.supple.run_hook("pre-receive", repo, updates)
+ local info = {
+ username = username,
+ keytag = keytag,
+ source = source,
+ realname = (config.users[username] or {}).real_name or "",
+ email = (config.users[username] or {}).email_address or "",
+ }
+ local ok, msg = gitano.supple.run_hook("pre-receive", repo, info, updates)
if not ok then
gitano.log.crit(msg or "No reason given, but errored somehow.")
end
diff --git a/bin/gitano-update-hook.in b/bin/gitano-update-hook.in
index 7658d0d..dd81649 100644
--- a/bin/gitano-update-hook.in
+++ b/bin/gitano-update-hook.in
@@ -255,7 +255,14 @@ if repo:uses_hook("update") then
gitano.log.debug("Configuring for update hook")
gitano.actions.set_supple_globals("update")
gitano.log.info("Running repository update hook")
- local ok, msg = gitano.supple.run_hook("update", repo,
+ local info = {
+ username = username,
+ keytag = keytag,
+ source = source,
+ realname = (config.users[username] or {}).real_name or "",
+ email = (config.users[username] or {}).email_address or "",
+ }
+ local ok, msg = gitano.supple.run_hook("update", repo, info,
refname, oldsha, newsha)
if not ok then
gitano.log.fatal(msg or "No reason given to refuse action.")
diff --git a/lib/gitano/supple.lua b/lib/gitano/supple.lua
index e347954..2627c45 100644
--- a/lib/gitano/supple.lua
+++ b/lib/gitano/supple.lua
@@ -122,18 +122,23 @@ load_module = nil
function require(modname)
return loadmodule(modname)()
end
-return (function(hookname, repo, ...)
+return (function(hookname, repo, info, ...)
local hookf = loadmodule("hooks." .. hookname)
local ghookf = loadmodule("globalhooks." .. hookname)
+ actor = {}
+ for k, v in pairs(info) do
+ actor[k] = v
+ end
+ info = nil
return ghookf(hookf, repo, ...)
end)(...)
]]
-local function run_hook(hook, repo, ...)
+local function run_hook(hook, repo, info, ...)
local proxy = get_repo_proxy(repo)
log.ddebug("Entering supple.host.run()")
return supple.host.run(supple_runtime_code, "@gitano.supple.runtime",
- hook, proxy, ...)
+ hook, proxy, info, ...)
end
return {