2022-02-14 19:41:55 +01:00
|
|
|
import { exec } from "child_process"
|
2023-03-29 17:21:20 +02:00
|
|
|
import { writeFileSync } from "fs"
|
2022-02-14 19:41:55 +01:00
|
|
|
|
2023-02-01 11:57:26 +01:00
|
|
|
interface Contributor {
|
|
|
|
/**
|
|
|
|
* The name of the contributor
|
|
|
|
*/
|
|
|
|
contributor: string
|
|
|
|
/**
|
|
|
|
* The number of commits
|
|
|
|
*/
|
|
|
|
commits: number
|
|
|
|
}
|
|
|
|
|
|
|
|
interface ContributorList {
|
|
|
|
contributors: Contributor[]
|
|
|
|
}
|
|
|
|
|
|
|
|
function asList(hist: Map<string, number>): ContributorList {
|
|
|
|
const ls: Contributor[] = []
|
2022-02-14 19:41:55 +01:00
|
|
|
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
|
2022-04-15 01:01:10 +02:00
|
|
|
if (
|
|
|
|
message.startsWith("Translated using Weblate") ||
|
|
|
|
message.startsWith("Translated using Hosted Weblate")
|
|
|
|
) {
|
2022-02-14 19:41:55 +01:00
|
|
|
hist = translationContributors
|
|
|
|
}
|
|
|
|
hist.set(author, 1 + (hist.get(author) ?? 0))
|
|
|
|
}
|
2022-09-08 21:40:48 +02:00
|
|
|
|
2022-02-14 19:41:55 +01:00
|
|
|
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-09-08 21:40:48 +02:00
|
|
|
)
|
2022-02-14 19:41:55 +01:00
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|