diff options
-rw-r--r-- | bin/gitano-auth.in | 16 | ||||
-rw-r--r-- | lib/gitano/admincommand.lua | 16 | ||||
-rw-r--r-- | lib/gitano/auth.lua | 11 |
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 |