diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-10-13 15:59:59 +0200 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2015-10-13 15:59:59 +0200 |
commit | 474f4298edf7992e4d4a10888df04ac112ce774f (patch) | |
tree | f10ac05bbfbe790065fa2f61b5da036249c31236 | |
parent | 664c812884d764515594db6b971f344d0998c832 (diff) | |
download | gitano-474f4298edf7992e4d4a10888df04ac112ce774f.tar.bz2 |
Merge archiverepo work
-rw-r--r-- | lib/gitano/command.lua | 28 | ||||
-rw-r--r-- | testing/01-basics.yarn | 6 | ||||
-rw-r--r-- | testing/02-commands-ls.yarn | 21 |
3 files changed, 45 insertions, 10 deletions
diff --git a/lib/gitano/command.lua b/lib/gitano/command.lua index 468b34b..5cef86c 100644 --- a/lib/gitano/command.lua +++ b/lib/gitano/command.lua @@ -837,13 +837,14 @@ assert(register_cmd("rename", builtin_rename_short, builtin_rename_helptext, local builtin_ls_short = "List repositories on the server" local builtin_ls_helptext = [[ -usage: ls [--verbose|-v] [<pattern>...] +usage: ls [--verbose|-v] [--all|-a] [<pattern>...] List repositories on the server. If you do not provide a pattern then all repositories are considered, otherwise only ones which match the given patterns will be considered. If you specify --verbose then the head ref name and the description will be provided in addition to the access rights and repository -name, separated by tabs. +name, separated by tabs. If you specify --all then repositories which you +have access to, but have been marked as archived will also be displayed. Patterns are a type of extended glob style syntax: @@ -880,12 +881,24 @@ do end end +local lsargs = { + ["--verbose"] = "verbose", + ["-v"] = "verbose", + ["--all"] = "all", + ["-a"] = "all", +} + local function builtin_ls_run(config, _, cmdline, env) -- Step one, parse each pattern into a lua pattern local pats = {} - local firstpat, verbose = 2, false - if cmdline[firstpat] == "--verbose" or cmdline[firstpat] == "-v" then - firstpat, verbose = 3, true + local firstpat, verbose, all = 2, false, false + while lsargs[cmdline[firstpat]] do + if lsargs[cmdline[firstpat]] == "verbose" then + firstpat, verbose = firstpat + 1, true + end + if lsargs[cmdline[firstpat]] == "all" then + firstpat, all = firstpat + 1, true + end end for i = firstpat, #cmdline do local pat, c, input = "", "", cmdline[i] @@ -958,6 +971,8 @@ local function builtin_ls_run(config, _, cmdline, env) end local function callback(reponame, repo, msg) if repo then + local archived = repo:conf_get("project.archived") + if archived and not all then return end local ctx = util.deep_copy(_ctx) ctx.operation = "read" local action, reason = repo:run_lace(ctx) @@ -971,7 +986,8 @@ local function builtin_ls_run(config, _, cmdline, env) desc = desc:gsub("\n.*", "") tail = " " .. repo:conf_get("project.head") .. " " .. desc end - log.stdout(action == "allow" and "RW" or "R ", repo.name .. tail) + log.stdout((action == "allow" and "RW" or "R ") .. + (archived and "A" or " "), repo.name .. tail) end end end diff --git a/testing/01-basics.yarn b/testing/01-basics.yarn index 18f2e4f..3029f16 100644 --- a/testing/01-basics.yarn +++ b/testing/01-basics.yarn @@ -77,7 +77,7 @@ when the new user runs 'ls' it doesn't get to see `gitano-admin` but that the AND alice main runs ls THEN stdout does not contain gitano-admin WHEN testinstance adminkey runs ls - THEN stdout contains RW gitano-admin + THEN stdout contains RW \ gitano-admin Basic repository creation ------------------------- @@ -94,13 +94,13 @@ test that a new user who has a repository created for them can see it in ls. WHEN testinstance, using adminkey, adds user alice, using alice main AND testinstance adminkey runs create somerepo alice AND alice main runs ls - THEN stdout contains RW somerepo + THEN stdout contains RW \ somerepo And just to check, if the `testinstance` user created a non-delegated repo then the `alice` user cannot see it. WHEN testinstance adminkey runs create anotherrepo AND testinstance adminkey runs ls - THEN stdout contains RW anotherrepo + THEN stdout contains RW \ anotherrepo WHEN alice main runs ls THEN stdout does not contain anotherrepo diff --git a/testing/02-commands-ls.yarn b/testing/02-commands-ls.yarn index 6a6178c..ad6fd08 100644 --- a/testing/02-commands-ls.yarn +++ b/testing/02-commands-ls.yarn @@ -17,7 +17,7 @@ repositories. SCENARIO Basic operation of ls GIVEN a standard instance WHEN testinstance adminkey runs ls - THEN stdout contains RW gitano-admin + THEN stdout contains RW \ gitano-admin AND stderr is empty General access control for ls @@ -35,4 +35,23 @@ when you run `ls`. THEN stdout does not contain stoat AND stderr is empty +Check listing of archived repositories +====================================== + +When a repository is marked as archived, it should not show up when you +run `ls` even if you have access, unless you pass `--all` to the ls command. + + SCENARIO Archived repositories do not show in ls + GIVEN a standard instance + WHEN testinstance adminkey runs ls + THEN stdout contains gitano-admin + AND stderr is empty + WHEN testinstance adminkey runs config gitano-admin set project.archived true + AND testinstance adminkey runs ls + THEN stdout does not contain gitano-admin + AND stderr is empty + WHEN testinstance adminkey runs ls --all + THEN stdout contains RWA gitano-admin + AND stderr is empty + TODO: Add more tests when we have rule control to govern things a little more. |