Skip to content

Commit 68fa850

Browse files
author
Dmitry Olshansky
committed
Now using dub with libdparse
1 parent 48a97ba commit 68fa850

File tree

3 files changed

+32
-4
lines changed

3 files changed

+32
-4
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
.dub
2+
docs.json
3+
__dummy.html
14
*.o
25
*.obj

dub.json

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"name": "gchunt",
3+
"description": "A tool to post-process D compiler's GC usage log",
4+
"copyright": "Copyright © 2014, Dmitry Olshansky",
5+
"authors": ["Dmitry Olshansky"],
6+
"dependencies": {
7+
"libdparse": ">=0.1.1"
8+
},
9+
"targetType" : "executable",
10+
"targetName" : "gchunt"
11+
}

gchunt.d source/gchunt.d

+18-4
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,24 @@ string gitHEAD()
9090
return m[1];
9191
}
9292

93+
string gitRemotePath()
94+
{
95+
auto ret = execute(["git", "remote", "-v"]);
96+
enforce(ret.status == 0);
97+
auto m = ret.output.matchFirst(`origin\s*(.+) \(fetch\)`);
98+
enforce(m, "broken git log");
99+
//NOTE: matching others remotes can be hacked here
100+
m = m[1].matchFirst(`github.com[:/](.*)/(\S+)\.git`);
101+
enforce(m, "failed to find origin remote");
102+
return m[1]~"/"~m[2];
103+
}
104+
93105

94106
void main(){
95-
string gitHash = gitHEAD;
96-
string gitRepo = `https://github.com/D-Programming-Language/`;
107+
string fmt = "mediawiki";
108+
string gitHost = `https://github.com`;
109+
string gitHash = gitHEAD();
110+
string gitRepo = gitRemotePath();
97111
auto re = regex(`(.*[\\/]\w+)\.d\((\d+)\):\s*vgc:\s*(.*)`);
98112
//writeln(`std\variant.d(236): vgc: 'new' causes GC allocation`.match(re));
99113
Result[] results;
@@ -108,7 +122,7 @@ void main(){
108122
results = uniq(results).array;
109123

110124
string linkTemplate =
111-
`[%s/phobos/blob/%s/%s.d#L%s %s]`;
125+
`[%s/%s/blob/%s/%s.d#L%s %s]`;
112126
writeln(`
113127
{| class="wikitable"
114128
! Module
@@ -121,7 +135,7 @@ void main(){
121135
auto mod = r.file.replace("/", ".");
122136
auto artifact = findAtrifact(r);
123137
if(!artifact.endsWith("unittest")){
124-
auto link = format(linkTemplate, gitRepo, gitHash, r.file, r.line, mod);
138+
auto link = format(linkTemplate, gitHost, gitRepo, gitHash, r.file, r.line, mod);
125139
writef("|%s\n|%s\n|%s\n| ???\n|-\n", link, artifact, r.reason);
126140
}
127141
}

0 commit comments

Comments
 (0)