diff options
author | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-08-30 23:07:49 +0100 |
---|---|---|
committer | Daniel Silverstone <dsilvers@digital-scurf.org> | 2012-08-30 23:07:49 +0100 |
commit | c45f8a3af03e5fc3432a9585184f056a5bf694b7 (patch) | |
tree | 92f92def8cf012e23161475cdc7c877a904cf704 /lib | |
parent | 9e042f25f2bfa9f799e9511d6224659545bd6064 (diff) | |
download | gitano-c45f8a3af03e5fc3432a9585184f056a5bf694b7.tar.gz |
COMMAND: Use the new filter function in the ls command
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitano/command.lua | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/gitano/command.lua b/lib/gitano/command.lua index 4d69780..aa33083 100644 --- a/lib/gitano/command.lua +++ b/lib/gitano/command.lua @@ -876,9 +876,9 @@ local function builtin_ls_run(config, _, cmdline, env) pat = pat .. ".*" end if used_evil then - pat = "^/" .. pat .. "$" + pat = "^/" .. pat .. "%.git$" else - pat = "/" .. pat .. "$" + pat = "/" .. pat .. "%.git$" end log.debug("PAT:", pat) pats[#pats+1] = pat @@ -889,17 +889,15 @@ local function builtin_ls_run(config, _, cmdline, env) -- Now we iterate all the repositories, listing them if (a) they pass a -- pattern and (b) they allow the current user to read. local _ctx = cmdline._ctx - local function callback(reponame, repo, msg) - local ok = false - if repo then - for i = 1, #pats do - if ("/" .. repo.name):match(pats[i]) then - ok = true - i = #pats - end + local function filter_callback(name) + for i = 1, #pats do + if ("/" .. name):match(pats[i]) then + return true end end - if ok then + end + local function callback(reponame, repo, msg) + if repo then local ctx = util.deep_copy(_ctx) ctx.operation = "read" local action, reason = repo:run_lace(ctx) @@ -911,7 +909,7 @@ local function builtin_ls_run(config, _, cmdline, env) end end end - repository.foreach(config, callback) + repository.foreach(config, callback, filter_callback) return "exit", 0 end |