4 from collections import defaultdict
6 codefiles = r"(\.[ch](pp)?|\.lua|\.md|\.cmake|\.java|\.gradle|Makefile|CMakeLists\.txt)$"
8 # two minor versions back, for "Active Contributors"
9 REVS_ACTIVE = "5.2.0..HEAD"
10 # all time, for "Previous Contributors"
11 REVS_PREVIOUS = "HEAD"
16 # For a description of the points system see:
17 # https://github.com/minetest/minetest/pull/9593#issue-398677198
20 points = defaultdict(int)
21 p = subprocess.Popen(["git", "log", "--mailmap", "--pretty=format:%h %aN <%aE>", revs],
22 stdout=subprocess.PIPE, universal_newlines=True)
24 hash, author = line.strip().split(" ", 1)
27 p2 = subprocess.Popen(["git", "show", "--numstat", "--pretty=format:", hash],
28 stdout=subprocess.PIPE, universal_newlines=True)
29 for line in p2.stdout:
30 added, deleted, filename = re.split(r"\s+", line.strip(), 2)
31 if re.search(codefiles, filename) and added != "-":
48 # Some authors duplicate? Don't add manual workarounds here, edit the .mailmap!
49 for author in ("updatepo.sh <script@mt>", "Weblate <42@minetest.ru>"):
50 points.pop(author, None)
53 points_active = load(REVS_ACTIVE)
54 points_prev = load(REVS_PREVIOUS)
56 with open("results.txt", "w") as f:
57 for author, points in sorted(points_active.items(), key=(lambda e: e[1]), reverse=True):
58 if points < CUTOFF_ACTIVE: break
59 points_prev.pop(author, None) # active authors don't appear in previous
60 f.write("%d\t%s\n" % (points, author))
61 f.write('\n---------\n\n')
63 for author, points in sorted(points_prev.items(), key=(lambda e: e[1]), reverse=True):
64 if points < CUTOFF_PREVIOUS and once:
65 f.write('\n---------\n\n')
67 f.write("%d\t%s\n" % (points, author))