2023-04-15 21:25:14 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
# This is based on the gather_git_credits.py script from the Minetest
|
2023-04-15 21:50:47 +02:00
|
|
|
# repository. It has been modified to go back six months for active contributors
|
|
|
|
# (instead of two minor releases) and only take into account the number of
|
|
|
|
# changes, not the number of commits.
|
2023-04-15 21:25:14 +02:00
|
|
|
|
|
|
|
import subprocess
|
|
|
|
import re
|
|
|
|
from collections import defaultdict
|
|
|
|
|
|
|
|
codefiles = r".lua$"
|
|
|
|
|
2023-04-15 21:50:47 +02:00
|
|
|
# the past six months, for "Active Contributors"
|
|
|
|
SINCE_ACTIVE = "six months ago ago"
|
2023-04-15 21:25:14 +02:00
|
|
|
# all time, for "Previous Contributors"
|
2023-04-15 21:50:47 +02:00
|
|
|
SINCE_PREVIOUS = "1970"
|
2023-04-15 21:25:14 +02:00
|
|
|
|
|
|
|
CUTOFF_ACTIVE = 150
|
|
|
|
CUTOFF_PREVIOUS = 1050
|
|
|
|
|
2023-04-15 21:50:47 +02:00
|
|
|
def load(since):
|
2023-04-15 21:25:14 +02:00
|
|
|
points = defaultdict(int)
|
2023-04-15 21:50:47 +02:00
|
|
|
p = subprocess.Popen(["git", "log", "--mailmap", "--pretty=format:%h %aN <%aE>", "--since", since],
|
2023-04-15 21:25:14 +02:00
|
|
|
stdout=subprocess.PIPE, universal_newlines=True)
|
|
|
|
for line in p.stdout:
|
|
|
|
hash, author = line.strip().split(" ", 1)
|
|
|
|
n = 0
|
|
|
|
|
|
|
|
p2 = subprocess.Popen(["git", "show", "--numstat", "--pretty=format:", hash],
|
|
|
|
stdout=subprocess.PIPE, universal_newlines=True)
|
|
|
|
for line in p2.stdout:
|
|
|
|
added, deleted, filename = re.split(r"\s+", line.strip(), 2)
|
|
|
|
if re.search(codefiles, filename) and added != "-":
|
|
|
|
n += int(added)
|
|
|
|
p2.wait()
|
|
|
|
|
|
|
|
points[author] += n
|
|
|
|
p.wait()
|
|
|
|
|
|
|
|
# Some authors duplicate? Don't add manual workarounds here, edit the .mailmap!
|
|
|
|
for author in ("updatepo.sh <script@mt>", "Weblate <42@minetest.ru>"):
|
|
|
|
points.pop(author, None)
|
|
|
|
return points
|
|
|
|
|
2023-04-15 21:50:47 +02:00
|
|
|
points_active = load(SINCE_ACTIVE)
|
|
|
|
points_prev = load(SINCE_PREVIOUS)
|
2023-04-15 21:25:14 +02:00
|
|
|
|
|
|
|
with open("results.txt", "w") as f:
|
|
|
|
for author, points in sorted(points_active.items(), key=(lambda e: e[1]), reverse=True):
|
|
|
|
if points < CUTOFF_ACTIVE: break
|
|
|
|
points_prev.pop(author, None) # active authors don't appear in previous
|
|
|
|
f.write("%d\t%s\n" % (points, author))
|
|
|
|
f.write('\n---------\n\n')
|
|
|
|
once = True
|
|
|
|
for author, points in sorted(points_prev.items(), key=(lambda e: e[1]), reverse=True):
|
|
|
|
if points < CUTOFF_PREVIOUS and once:
|
|
|
|
f.write('\n---------\n\n')
|
|
|
|
once = False
|
|
|
|
f.write("%d\t%s\n" % (points, author))
|