// this function takes a line that may contain a name and/or email address, // and returns just the name, while fixing the "bad cases".
std::string contributor_name(const std::string& line)
{
string result;
// let's first take care of the case of isolated email addresses, like // "user@localhost.localdomain" entries if(line.find("markb@localhost.localdomain") != string::npos)
{ return"Mark Borgerding";
}
// from there on we assume that we have a entry of the form // either: // Bla bli Blurp // or: // Bla bli Blurp <bblurp@email.com>
size_t position_of_email_address = line.find_first_of('<'); if(position_of_email_address != string::npos)
{ // there is an e-mail address in <...>.
// Hauke once committed as "John Smith", fix that. if(line.find("hauke.heibel") != string::npos)
result = "Hauke Heibel"; else
{ // just remove the e-mail address
result = line.substr(0, position_of_email_address);
}
} else
{ // there is no e-mail address in <...>.
if(line.find("convert-repo") != string::npos)
result = ""; else
result = line;
}
// parses hg churn output to generate a contributors map.
map<string,int> contributors_map_from_churn_output(constchar *filename)
{
map<string,int> contributors_map;
string line;
ifstream churn_out;
churn_out.open(filename, ios::in); while(!getline(churn_out,line).eof())
{ // remove the histograms "******" that hg churn may draw at the end of some lines
size_t first_star = line.find_first_of('*'); if(first_star != string::npos) line.erase(first_star);
// now the last space indicates where the number starts
size_t last_space = line.find_last_of(' ');
// get the number (of changesets or of modified lines for each contributor) int number;
istringstream(line.substr(last_space+1)) >> number;
// get the name of the contributor
line.erase(last_space);
string name = contributor_name(line);
map<string,int>::iterator it = contributors_map.find(name); // if new contributor, insert if(it == contributors_map.end())
contributors_map.insert(pair<string,int>(name, number)); // if duplicate, just add the number else
it->second += number;
}
churn_out.close();
return contributors_map;
}
// find the last name, i.e. the last word. // for "van den Schbling" types of last names, that's not a problem, that's actually what we want.
string lastname(const string& name)
{
size_t last_space = name.find_last_of(' '); if(last_space >= name.length()-1) return name; elsereturn name.substr(last_space+1);
}
struct contributor
{
string name; int changedlines; int changesets;
string url;
string misc;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.