summaryrefslogtreecommitdiff
path: root/activity/git.lua
diff options
context:
space:
mode:
Diffstat (limited to 'activity/git.lua')
-rw-r--r--activity/git.lua27
1 files changed, 21 insertions, 6 deletions
diff --git a/activity/git.lua b/activity/git.lua
index 978dfec..160d227 100644
--- a/activity/git.lua
+++ b/activity/git.lua
@@ -2,16 +2,19 @@ local dates = require "activity.dates"
local git = {}
-function git.log (dirname, entries)
+function git.log (dirname, entries, filter)
entries = entries or {}
if not dirname then
error "did not provide repo"
end
- local handle = io.popen(([[git -C %s log --format="%%aE;%%as"]]):format(dirname))
+ local handle = io.popen(([[git -C %s log --all --format="%%aE;%%cE;%%as"]]):format(dirname))
for line in handle:lines() do
- local email, year, month, day = line:match"([^;]*);(%d+)%-(%d+)%-(%d+)"
+ local author, committer, year, month, day = line:match"([^;]*);([^;]*);(%d+)%-(%d+)%-(%d+)"
local date = {year=tonumber(year), month=tonumber(month), day=tonumber(day)}
- table.insert(entries, {email=email, date=date})
+ local entry = {author=author, committer=committer, date=date}
+ if not filter or filter(entry) then
+ table.insert(entries, entry)
+ end
end
local ok, _ = handle:close()
if not ok then
@@ -21,11 +24,11 @@ function git.log (dirname, entries)
end
-function git.lookup (repositories)
+function git.lookup (repositories, filter)
local lookup = {}
local entries = {}
for _, dirname in pairs(repositories) do
- git.log(dirname, entries)
+ git.log(dirname, entries, filter)
end
for _, entry in pairs(entries) do
local day = dates.day_of_year(entry.date)
@@ -39,4 +42,16 @@ function git.lookup (repositories)
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
+ end
+ return false
+ end
+end
+
+
return git