public
Last active

Changed - a changelog fabricator for D

  • Download Gist
changed.d
D
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 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
///Written in the D programming language
/**
A script to fetch bugfixes from D Bugzilla between given dates and print them out in DDoc form.
*/
module changed;
 
import std.net.curl, std.conv, std.exception, std.algorithm, std.csv, std.typecons,
std.stdio, std.datetime, std.array, std.string, std.format, std.getopt;
 
auto templateRequest =
`http://d.puremagic.com/issues/buglist.cgi?username=crap2crap%40yandex.ru&password=powerlow7&chfieldto={to}&query_format=advanced&chfield=resolution&chfieldfrom={from}&bug_status=RESOLVED&resolution=FIXED&product=D&ctype=csv&columnlist=component%2Cbug_severity%2Cshort_desc`;
 
auto generateRequest(string templ, Date start, Date end)
{
auto ss = format("%04s-%02s-%02s", start.year, to!int(start.month), start.day);
auto es = format("%04s-%02s-%02s", end.year, to!int(end.month), end.day);
return templateRequest.replace("{from}", ss).replace("{to}", es);
}
 
auto dateFromStr(string sdate)
{
int year, month, day;
formattedRead(sdate, "%s-%s-%s", &year, &month, &day);
return Date(year, month, day);
}
 
struct Entry
{
int id;
string severity, summary;
}
 
int main(string[] args)
{
string start_date, end_date;
bool ddoc = false;
getopt(args,
"start", &start_date, // numeric
"end", &end_date); // string
if(start_date.empty)
{
writefln("*ERROR: No start date set.\nUsage example:\n%s --start=YYYY-MM-HH [--end=YYYY-MM-HH] ", args[0]);
return 1;
}
auto start = dateFromStr(start_date);
auto end = end_date.empty ? to!Date(Clock.currTime()) : dateFromStr(end_date);
auto req = generateRequest(templateRequest, start, end);
stderr.writeln(req);
auto data = req.get;
Entry[] dmd, druntime, phobos;
//stderr.writeln(data);
foreach(fields; csvReader!(Tuple!(int, string, string, string))(data, null))
{
//auto fields = splitCSV(line);
switch(fields[1].toUpper()){
case "DMD":
dmd ~= Entry(fields[0], fields[2], fields[3].idup);
break;
case "DRUNTIME":
druntime ~= Entry(fields[0], fields[2].idup, fields[3].idup);
break;
case "PHOBOS":
phobos ~= Entry(fields[0], fields[2].idup, fields[3].idup);
break;
default:
stderr.writeln("Skipping Issue ", fields[0], " Component: ", fields[1]);
}
}
void writeEntry(Entry e)
{
writefln("$(LI $(BUGZILLA %s): %s)", e.id, e.summary);
}
writeln("$(DMDBUGSFIXED ");
foreach(e; sort!"a.id < b.id"(dmd))
writeEntry(e);
writeln(")");
writeln("$(RUNTIMEBUGSFIXED ");
foreach(e; sort!"a.id < b.id"(druntime))
writeEntry(e);
writeln(")");
writeln("$(LIBBUGSFIXED ");
foreach(e; sort!"a.id < b.id"(phobos))
writeEntry(e);
writeln(")");
return 0;
}

Usage: rdmd changed.d --start=2012-08-02
to get what would be changelog entries for upcoming 2.061

rdmd changed.d --start=2012-04-12 --end=2012-08-02 > changlog.dd
Would get 2.060 changelog and show that there are some bugs that were indeed fixed but not currently listed on dlang.org e.g issue 2006.

Mhm std.datetime months are now printed as abbreviations by default, odd.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.