diff options
author | Aki <please@ignore.pl> | 2024-02-21 00:21:37 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-02-21 00:21:37 +0100 |
commit | 838feeb02e4463e169688938a3e56a94b3d09bef (patch) | |
tree | 082c15b243d86b9fba98443ba233a647847b5a57 /activity.lua | |
parent | 90be8407ccc34a0ee26ee25b1ff1384c393138c0 (diff) | |
download | activity-838feeb02e4463e169688938a3e56a94b3d09bef.zip activity-838feeb02e4463e169688938a3e56a94b3d09bef.tar.gz activity-838feeb02e4463e169688938a3e56a94b3d09bef.tar.bz2 |
Added -B option to filter by author and committer with one command
Diffstat (limited to 'activity.lua')
-rwxr-xr-x | activity.lua | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/activity.lua b/activity.lua index a97e79d..f33774a 100755 --- a/activity.lua +++ b/activity.lua @@ -5,6 +5,7 @@ Generates activity chart -y (optional number) Generate yearly chart for selected year -A... (optional string) Author e-mail addresses to include in chart -C... (optional string) Committer e-mail addresses to include in chart + -B... (optional string) Author or committer e-mail addresses to include <repos...> (optional string) Paths to repositories with activity By default, tool will generate a rolling chart for selected repositories. If no @@ -12,6 +13,7 @@ repositories were selected, current working directory will be tried. ]] local generators = require "activity.generators" local git = require "activity.git" +local tablex = require "pl.tablex" local ok, maybe_format = pcall(require, "activity.formats." .. args.f) if not ok then io.stderr:write(("could not find specified format: %q\n\n"):format(args.f)) @@ -22,13 +24,10 @@ local maybe_year = args.y or "rolling" if #args.repos < 1 then table.insert(args.repos, ".") end -local filter, by_author, by_committer -if #args.A > 0 then - by_author = git.any_value_filter("author", args.A) -end -if #args.C > 0 then - by_committer = git.any_value_filter("committer", args.C) -end +local by_both = tablex.makeset(args.B) +local by_author = git.maybe_filter("author", tablex.union(tablex.makeset(args.A), by_both)) +local by_committer = git.maybe_filter("committer", tablex.union(tablex.makeset(args.C), by_both)) +local filter if by_committer and by_author then function filter (entry) return by_author(entry) or by_committer(entry) |