mirror of
https://github.com/SquidDev-CC/CC-Tweaked
synced 2025-01-15 11:45:42 +00:00
Improvements to contribution generation
- Parse Co-authored-by lines too. There's several contributors (mostly via weblate, but a few GH ones too) who weren't credited otherwise. - Add support for git mailmap, remapping some emails to a canonnical username. This allows us to remove some duplicates - nobody needs both SquidDev and "Jonathan Coates." I'm not making this file public, as it contains email addresses. This does mean that CI builds will still contain the full list with duplicates.
This commit is contained in:
parent
c981c75b7c
commit
d631111610
29
build.gradle
29
build.gradle
@ -220,9 +220,32 @@ processResources {
|
|||||||
try {
|
try {
|
||||||
hash = ["git", "-C", projectDir, "rev-parse", "HEAD"].execute().text.trim()
|
hash = ["git", "-C", projectDir, "rev-parse", "HEAD"].execute().text.trim()
|
||||||
|
|
||||||
def blacklist = ['GitHub', 'dan200', 'Daniel Ratcliffe']
|
def blacklist = ['GitHub', 'Daniel Ratcliffe', 'Weblate']
|
||||||
["git", "-C", projectDir, "log", "--format=tformat:%an%n%cn"].execute().text.split('\n').each {
|
|
||||||
if (!blacklist.contains(it)) contributors.add(it)
|
// Extract all authors, commiters and co-authors from the git log.
|
||||||
|
def authors = ["git", "-C", projectDir, "log", "--format=tformat:%an <%ae>%n%cn <%ce>%n%(trailers:key=Co-authored-by,valueonly)"]
|
||||||
|
.execute().text.readLines().unique()
|
||||||
|
|
||||||
|
// We now pass this through git's mailmap to de-duplicate some authors.
|
||||||
|
def remapAuthors = ["git", "check-mailmap", "--stdin"].execute()
|
||||||
|
remapAuthors.withWriter { stdin ->
|
||||||
|
if (stdin !instanceof BufferedWriter) stdin = new BufferedWriter(stdin)
|
||||||
|
|
||||||
|
authors.forEach {
|
||||||
|
if (it == "") return
|
||||||
|
if (!it.endsWith(">")) it += ">" // Some commits have broken Co-Authored-By lines!
|
||||||
|
stdin.writeLine(it)
|
||||||
|
}
|
||||||
|
stdin.close()
|
||||||
|
}
|
||||||
|
|
||||||
|
// And finally extract out the actual name.
|
||||||
|
def emailRegex = ~/^([^<]+) <.+>$/
|
||||||
|
remapAuthors.text.readLines().forEach {
|
||||||
|
def matcher = it =~ emailRegex
|
||||||
|
matcher.find()
|
||||||
|
def name = matcher.group(1)
|
||||||
|
if (!blacklist.contains(name)) contributors.add(name)
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
|
Loading…
Reference in New Issue
Block a user