summaryrefslogtreecommitdiff
path: root/lib/gitano/config.lua
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-10 11:01:29 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2012-08-10 11:01:38 +0100
commitd0c22665a7a4ddbe2af447a5daf28d51c734ae6a (patch)
treec20198f58a0cea1a710a5116b06896a3f44af270 /lib/gitano/config.lua
parent07cb69c35349fddcc4645754f28adc3218080de0 (diff)
downloadgitano-d0c22665a7a4ddbe2af447a5daf28d51c734ae6a.tar.gz
GITANO: Switch all current hooks (update, post-receive) to use Supple
Diffstat (limited to 'lib/gitano/config.lua')
-rw-r--r--lib/gitano/config.lua25
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/gitano/config.lua b/lib/gitano/config.lua
index 4ff8868..f49d4cb 100644
--- a/lib/gitano/config.lua
+++ b/lib/gitano/config.lua
@@ -239,6 +239,28 @@ local function parse_admin_config(commit)
return config
end
+local function load_file_content(conf, filename)
+ local entry = conf.content[filename]
+ if not entry then
+ return nil, "Not found: " .. conf.commit.sha .. "::" .. filename
+ end
+ if entry.type ~= "blob" then
+ return nil, conf.commit.sha .. "::" .. filename .. ": Not a blob"
+ end
+ return entry.obj.content, conf.commit.sha .. "::" .. filename
+end
+
+local function has_global_hook(conf, hook)
+ return (conf.content["global-hooks/" .. hook .. ".lua"] ~= nil and
+ conf.content["global-hooks/" .. hook .. ".lua"].type == "blob")
+end
+
+local function get_default_hook_content(conf, filename)
+ return [[
+(function(hookf, ...) return hookf(...) end)(...)
+]], conf.commit.sha .. "::[[" .. filename .. "]]"
+end
+
local function generate_ssh_config(conf)
local ret = {"","### Gitano Keys ###"}
for u, t in pairs(conf.users) do
@@ -417,4 +439,7 @@ return {
parse = parse_admin_config,
populate_context = populate_context,
commit = commit_config_changes,
+ load_file_content = load_file_content,
+ get_default_hook_content = get_default_hook_content,
+ has_global_hook = has_global_hook,
}