summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile3
-rw-r--r--activity.16
-rwxr-xr-xactivity.lua13
-rw-r--r--activity/git.lua12
4 files changed, 15 insertions, 19 deletions
diff --git a/Makefile b/Makefile
index 161fed2..eff7220 100644
--- a/Makefile
+++ b/Makefile
@@ -6,8 +6,7 @@ MANDIR=$(DATADIR)/man
MAN1DIR=$(MANDIR)/man1
LUA_LMOD=$(DATADIR)/lua/$(LUA_VERSION)
-all:
- @echo Nothing to be built
+all: test
install:
install -m644 -Dt $(DESTDIR)$(LUA_LMOD)/activity activity/*.lua
diff --git a/activity.1 b/activity.1
index 0ed1eb3..2e5a489 100644
--- a/activity.1
+++ b/activity.1
@@ -7,7 +7,7 @@ activity - generates a rolling or yearly activity chart for git repositories
.IR year ]
.RB [ \-f
.IR format ]
-.RB [ \-A | \-C
+.RB [ \-A | \-C | \-B
.IR email ]...
.RI [ repositories ]...
.SH DESCRIPTION
@@ -31,13 +31,13 @@ $ activity
.SS Generate SVG chart for 2023 for all repositories in a list
.RS
.EX
-$ xargs activity -y2023 -fsvg <repositories >activity.svh
+$ xargs activity \-y2023 \-fsvg <repositories >activity.svh
.EE
.RE
.SS Generate HTML5 rolling chart filtered by matching either author or committer in all repositories in a list
.RS
.EX
-$ xargs activity -Aplease@ignore.pl -Cplease@ignore.pl -fhtml5 <repositories >activity.html
+$ xargs activity \-Bplease@ignore.pl \-fhtml5 <repositories >activity.html
.EE
.RE
.SH SEE ALSO
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)
diff --git a/activity/git.lua b/activity/git.lua
index b24fc09..f25192c 100644
--- a/activity/git.lua
+++ b/activity/git.lua
@@ -44,15 +44,13 @@ function git.lookup (repositories, filter)
end
-function git.any_value_filter (member, values)
- return function (entry)
- for _, value in pairs(values) do
- if entry[member] == value then
- return true
- end
+function git.maybe_filter (field, set)
+ if next(set) then
+ return function (entry)
+ return set[entry[field]]
end
- return false
end
+ return nil
end