-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmergeAuthors.groovy
37 lines (30 loc) · 1.12 KB
/
mergeAuthors.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
def allAuthors = new File("resolvedAuthors.txt");
def mappedAuthors = new File("mappedAuthors.txt");
def mergedAuthors = new File("target/mergedAuthors.txt");
def authorsMap = new TreeMap(String.CASE_INSENSITIVE_ORDER);
def loadAuthors(authorsFile, authorsMap) {
def lineNum = 0;
authorsFile.eachLine { line ->
lineNum++;
line = line.trim();
if (line.length() == 0 || line.startsWith("#")) {
return;
}
def lineParts = line.split("=");
if (lineParts.length != 2) {
throw new Exception(authorsFile.toString() + " - Failed to parse line " + lineNum + ", it did not have two parts: " + line);
}
authorsMap.put(lineParts[0].trim(), lineParts[1].trim());
}
}
//Load list of all authors
loadAuthors(allAuthors, authorsMap);
//Load mapped authors (those with known github accounts)
loadAuthors(mappedAuthors, authorsMap);
//Write out merged authors file
mergedAuthors.getParentFile().mkdirs();
mergedAuthors.withWriter { writer ->
authorsMap.each() {svnAuth, gitAuth ->
writer.writeLine(svnAuth + " = " + gitAuth);
}
}