base: fixes regression test lua path
[luajson.git] / util / processShortlog.lua
blob3038984d415fdf458d23ece67e85ae936d4ee445
1 #!/usr/bin/env lua
2 local authors = {}
4 local currentAuthor
6 local function pushValue(t, group, value)
7 local items = t[group] or {}
8 t[group] = items
9 items[#items + 1] = value
10 end
11 for line in io.lines() do
12 local author = line:match("^(.- %(%d*%):)$")
13 line = line:match("^%s*(.-)%s*$")
14 if author then
15 currentAuthor = authors[author] or {}
16 authors[author] = currentAuthor
17 elseif currentAuthor and #line > 0 then
18 local msg = line:gsub("^%s*","")
19 local group, data = msg:match("^([^:]*[%s]*:)[%s]*(.*)$")
20 if not group then
21 pushValue(currentAuthor, "-ungrouped-", msg)
22 else
23 pushValue(currentAuthor, group, data)
24 end
25 end
26 end
27 for author, groups in pairs(authors) do
28 print(author)
29 -- SORT GROUPS
30 local sorted = {}
31 for group, groupValues in pairs(groups) do
32 sorted[#sorted + 1] = {group, groupValues}
33 end
34 table.sort(sorted, function(a,b) return a[1] < b[1] end)
35 for _, gv in ipairs(sorted) do
36 local group, groupValues = unpack(gv)
37 print("\t" .. group)
38 for _, entry in ipairs(groupValues) do
39 print("\t\t" .. entry)
40 end
41 end
42 end