Skip to content

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Changed - a changelog fabricator for D
///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;
}
@DmitryOlshansky

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

@DmitryOlshansky

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.

@DmitryOlshansky

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.