diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-09-01 10:29:04 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-09-01 10:29:04 +0100 |
commit | ddc9a9ca545529199e4dfbc33ef8ca9e708c6b60 (patch) | |
tree | 414156f315e468d42e11255c559983f2c31e681d | |
parent | 69bb19899d3651f8290b59002c0c9482bb8f3833 (diff) | |
parent | 22290b4a4d93ed7c36a84786551c65b9d36d336c (diff) | |
download | gitano-ddc9a9ca545529199e4dfbc33ef8ca9e708c6b60.tar.gz |
Merge branch 'rework-hooks-with-userinfo'
-rw-r--r-- | bin/gitano-post-receive-hook.in | 9 | ||||
-rw-r--r-- | bin/gitano-pre-receive-hook.in | 9 | ||||
-rw-r--r-- | bin/gitano-update-hook.in | 9 | ||||
-rw-r--r-- | lib/gitano/supple.lua | 14 |
4 files changed, 33 insertions, 8 deletions
diff --git a/bin/gitano-post-receive-hook.in b/bin/gitano-post-receive-hook.in index 797ce26..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(repo, "post-receive", 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 4dd6ff3..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(repo, "pre-receive", 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 980ebc2..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(repo, "update", + 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 3af7633..2627c45 100644 --- a/lib/gitano/supple.lua +++ b/lib/gitano/supple.lua @@ -122,19 +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(_repo, hook, ...) - repo = _repo - local proxy = get_repo_proxy(_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 { |