summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-03-10 14:59:59 +0000
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2014-03-11 14:04:53 +0000
commitc101d7d310b908ad88a61efb499b8ee14f94fdb5 (patch)
tree8626961426870cf181540bfb5511eacfdf3bbeb0
parentb4e1b4a3ef063e8447bb5299c7ea40ba9296b35d (diff)
downloadgitano-c101d7d310b908ad88a61efb499b8ee14f94fdb5.tar.gz
Use new configurable repository detectionbaserock/danielsilverstone/S10633-repo-detection
Each of these callsites independently detected repositories before. Now they use the configurable repository detection which means (a) they are unified in their behaviour and (b) they can take advantage of new commands which might not have repositories represented in the same way. Signed-off-by: Daniel Silverstone <daniel.silverstone@codethink.co.uk>
-rw-r--r--bin/gitano-auth.in16
-rw-r--r--lib/gitano/admincommand.lua16
-rw-r--r--lib/gitano/auth.lua11
3 files changed, 12 insertions, 31 deletions
diff --git a/bin/gitano-auth.in b/bin/gitano-auth.in
index 55712f4..3901166 100644
--- a/bin/gitano-auth.in
+++ b/bin/gitano-auth.in
@@ -105,18 +105,10 @@ if not cmd then
gitano.log.fatal("Unknown command: " .. parsed_cmdline[1])
end
-if cmd.takes_repo and #parsed_cmdline > 1 then
- -- Acquire the repository object for the target repo
- local msg
- repo, msg = gitano.repository.find(config, parsed_cmdline[2])
- if not repo then
- gitano.log.critical("Unable to locate repository.")
- gitano.log.critical(" * " .. (tostring(msg)))
- gitano.log.fatal("Cannot continue")
- end
-
- if repo.is_nascent then
- gitano.log.info("Repository " .. repo.name .. " is nascent")
+if cmd.takes_repo then
+ repo, parsed_cmdline = cmd.detect_repo(config, parsed_cmdline)
+ if not repo and not parsed_cmdline then
+ gitano.log.fatal("Failed to acquire repository object")
end
end
diff --git a/lib/gitano/admincommand.lua b/lib/gitano/admincommand.lua
index f565e96..d0d13ce 100644
--- a/lib/gitano/admincommand.lua
+++ b/lib/gitano/admincommand.lua
@@ -47,18 +47,12 @@ local function builtin_as_validate(config, _, cmdline)
cmdline.cmd = cmd
-- If the returned command needs a repo, find it (and save it for later)
local repo
- if cmd.takes_repo and #cmdline > 3 then
+ if cmd.takes_repo then
-- Acquire the repository object for the target repo
- local msg
- repo, msg = repository.find(config, cmdline[4])
- if not repo then
- log.critical("Unable to locate repository.")
- log.critical(" * " .. (tostring(msg)))
- log.fatal("Cannot continue")
- end
-
- if repo.is_nascent then
- log.info("Repository " .. repo.name .. " is nascent")
+ repo, cmdline.copy = cmd.detect_repo(config, cmdline.copy)
+ if not repo and not cmdline.copy then
+ log.error("Unable to continue")
+ return false
end
cmdline.repo = repo
end
diff --git a/lib/gitano/auth.lua b/lib/gitano/auth.lua
index 8cdd8ec..8f288e6 100644
--- a/lib/gitano/auth.lua
+++ b/lib/gitano/auth.lua
@@ -97,14 +97,9 @@ local function is_authorized(user, source, cmdline)
local repo
if cmd.takes_repo and #parsed_cmdline > 1 then
- -- Acquire the repository object for the target repo
- local msg
- repo, msg = repository.find(admin_conf, parsed_cmdline[2])
-
- if not repo then
- log.critical("Unable to locate repository.")
- log.critical(" * " .. (tostring(msg) or "No error"))
- return nil
+ repo, parsed_cmdline = cmd.detect_repo(admin_conf, parsed_cmdline)
+ if not repo and not parsed_cmdline then
+ return nil
end
end