summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gitano/lace.lua33
-rw-r--r--lib/gitano/repository.lua18
2 files changed, 38 insertions, 13 deletions
diff --git a/lib/gitano/lace.lua b/lib/gitano/lace.lua
index 97ed91b..53fe53e 100644
--- a/lib/gitano/lace.lua
+++ b/lib/gitano/lace.lua
@@ -86,19 +86,14 @@ local function _do_simple_match(ctx, key, matchtype, value)
if type(kk) == "string" then
return check(value, kk)
else
- if pat and kk[1] ~= nil then
- for i = 1, #kk do
- if check(value, kk[i]) then
- return true
- end
- end
- return false
- else
- if matchtype:sub(1,1) == "!" then
- return kk[value] == nil
- end
- return kk[value] ~= nil
+ local ret = false
+ for k in pairs(kk) do
+ ret = ret or check(value, k)
+ end
+ if matchtype:sub(1,1) == "!" then
+ ret = not ret
end
+ return ret
end
end
@@ -165,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()