2022-02-14 19:41:55 +01:00
|
|
|
import {exec} from "child_process";
|
|
|
|
import {writeFile, writeFileSync} from "fs";
|
|
|
|
|
2022-02-14 19:53:23 +01:00
|
|
|
function asList(hist: Map<string, number>): {contributors: { contributor: string, commits: number }[]
|
|
|
|
}{
|
2022-02-14 19:41:55 +01:00
|
|
|
const ls = []
|
|
|
|
hist.forEach((commits, contributor) => {
|
|
|
|
ls.push({commits, contributor})
|
|
|
|
})
|
|
|
|
ls.sort((a, b) => (b.commits - a.commits))
|
2022-02-14 19:53:23 +01:00
|
|
|
return {contributors: ls}
|
2022-02-14 19:41:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function main() {
|
|
|
|
exec("git log --pretty='%aN %%!%% %s' ", ((error, stdout, stderr) => {
|
|
|
|
|
|
|
|
const entries = stdout.split("\n").filter(str => str !== "")
|
|
|
|
const codeContributors = new Map<string, number>()
|
|
|
|
const translationContributors = new Map<string, number>()
|
|
|
|
for (const entry of entries) {
|
|
|
|
console.log(entry)
|
|
|
|
let [author, message] = entry.split("%!%").map(s => s.trim())
|
2022-02-14 19:53:23 +01:00
|
|
|
if(author === "Weblate"){
|
|
|
|
continue
|
|
|
|
}
|
2022-02-14 19:41:55 +01:00
|
|
|
if (author === "pietervdvn") {
|
|
|
|
author = "Pieter Vander Vennet"
|
|
|
|
}
|
|
|
|
let hist = codeContributors;
|
|
|
|
if (message.startsWith("Translated using Weblate")) {
|
|
|
|
hist = translationContributors
|
|
|
|
}
|
|
|
|
hist.set(author, 1 + (hist.get(author) ?? 0))
|
|
|
|
}
|
|
|
|
|
|
|
|
const codeContributorsTarget = "assets/contributors.json"
|
2022-04-09 17:48:22 +02:00
|
|
|
writeFileSync(codeContributorsTarget, JSON.stringify(asList(codeContributors), null, " "))
|
2022-02-14 19:41:55 +01:00
|
|
|
const translatorsTarget = "assets/translators.json"
|
2022-04-09 17:48:22 +02:00
|
|
|
writeFileSync(translatorsTarget, JSON.stringify(asList(translationContributors), null, " "))
|
2022-02-14 19:41:55 +01:00
|
|
|
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|