summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2013-11-15 16:53:46 +0000
committerDaniel Silverstone <dsilvers@digital-scurf.org>2013-11-15 16:53:46 +0000
commit90bc3aadc5809e347ee5903cb265578026a16122 (patch)
tree8d1cfd9726792d588b707297c0e2424a59ad4072
parent5e75621b1c9a389016bb9bf6daa2b2c0a1386e83 (diff)
downloadgitano-90bc3aadc5809e347ee5903cb265578026a16122.tar.gz
Expose project clod in the lace context
-rw-r--r--lib/gitano/lace.lua14
-rw-r--r--lib/gitano/repository.lua18
2 files changed, 31 insertions, 1 deletions
diff --git a/lib/gitano/lace.lua b/lib/gitano/lace.lua
index 25183ed..53fe53e 100644
--- a/lib/gitano/lace.lua
+++ b/lib/gitano/lace.lua
@@ -160,12 +160,24 @@ local base_compcontext = {
}
}
+local function cloddly_bless(ctx)
+ local function indexer(tab, name)
+ if name:sub(1,7) == "config/" then
+ tab[name] = _simple_match
+ log.ddebug("[lace] Auto-vivifying " .. name)
+ return _simple_match
+ end
+ end
+ setmetatable(ctx._lace.controltype, {__index = indexer})
+ return ctx
+end
+
local function compile_ruleset(repo, adminsha, globaladminsha)
-- repo is a gitano repository object.
-- We trust that we can compile the repo's ruleset which involves
-- finding the admin sha for the repo (unless given) and then the global
-- admin sha (unless given) and using that to compile a full ruleset.
- local compcontext = util.deep_copy(base_compcontext)
+ local compcontext = cloddly_bless(util.deep_copy(base_compcontext))
compcontext.repo = repo
if not repo.is_nascent then
if not adminsha then
diff --git a/lib/gitano/repository.lua b/lib/gitano/repository.lua
index 796e162..5d4a194 100644
--- a/lib/gitano/repository.lua
+++ b/lib/gitano/repository.lua
@@ -381,6 +381,24 @@ function repo_method:populate_context(context)
context["owner"] = self:conf_get "project.owner"
end
context["_repo"] = self
+ if not self.is_nascent then
+ local lists_to_add = {}
+ for k, v in self.project_config:each() do
+ if k:match("%.i_[0-9]+$") then
+ lists_to_add[k:gsub("%.i_[0-9]+$", "")] = true
+ else
+ local confkey = "config/" .. k:gsub("%.", "/")
+ context[confkey] = v
+ end
+ end
+ for k in pairs(lists_to_add) do
+ local confkey = "config/" .. k:gsub("%.", "/")
+ local vallist = self.project_config:get_list(k)
+ local valset = {}
+ for _, v in pairs(vallist) do valset[v] = true end
+ context[confkey] = valset
+ end
+ end
end
function repo_method:realise()