-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsvn-authors.sh
executable file
·69 lines (61 loc) · 1.61 KB
/
svn-authors.sh
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env php
<?php
// generates SVN authors list
// grab wiki text:
$contributors = array();
$dom = new DOMDocument;
$dom->loadHTMLFile('http://wiki.habariproject.org/en/Contributors');
$xpath = new DOMXpath($dom);
$rows = $xpath->query('//table/tr');
$firstRow = true;
foreach ($rows as $row) {
if ($firstRow) {
$firstRow = false;
continue;
}
$svnNames = explode(', ', trim($row->childNodes->item(1)->nodeValue));
$first = array_shift($svnNames);
$contributors[$first] = trim($row->childNodes->item(0)->nodeValue);
foreach ($svnNames as $svnName) {
$contributors[$svnName] = '@' . $first; // @ = link
}
}
// get authors from svn log
$rawAuthors = `svn log -q`;
if (!$rawAuthors) {
echo "No authors.\n";
exit(1);
}
// grab unique authors into $authors
$authors = array();
$rawAuthors = explode("\n", $rawAuthors);
foreach ($rawAuthors as $authorLine) {
if (!isset($authorLine[0]) || $authorLine[0] !== 'r') {
// not a revision line;
continue;
}
list(,$author) = explode('|', $authorLine, 3);
$author = trim($author);
if (!isset($authors[$author]) && $author != '(no author)') {
if (isset($contributors[$author])) {
$authors[$author] = $contributors[$author];
} else {
$authors[$author] = '';
}
}
}
// output
foreach ($authors as $user => $name) {
if (!$name) {
$name = "(no name)";
}
$userLower = strtolower($user);
if ($name[0] == '@') { // check for link
$userLower = substr($name, 1);
if (isset($contributors[$userLower])) {
$name = $contributors[$userLower];
}
$userLower = strtolower($userLower);
}
echo "{$user} = {$name} <{$userLower}@contrib.habariproject.org>\n";
}