From 307b8a6e6995b2c08fb71d7eea202e2ab0a8a204 Mon Sep 17 00:00:00 2001 From: Zach Mullen Date: Mon, 20 Dec 2010 15:33:21 -0500 Subject: CTest git update should pass the committer as well as the author --- Source/CTest/cmCTestGIT.cxx | 29 +++++++++++++++++++++++++++++ Source/CTest/cmCTestVC.cxx | 5 +++++ Source/CTest/cmCTestVC.h | 3 +++ 3 files changed, 37 insertions(+) diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index a6f10ec..3456ec4 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -526,6 +526,35 @@ private: } this->Rev.Date += tz; } + else if(strncmp(this->Line.c_str(), "committer ", 10) == 0) + { + Person committer; + this->ParsePerson(this->Line.c_str()+10, committer); + this->Rev.Committer = committer.Name; + this->Rev.CommitterEMail = committer.EMail; + + // Convert the time to a human-readable format that is also easy + // to machine-parse: "CCYY-MM-DD hh:mm:ss". + time_t seconds = static_cast(committer.Time); + struct tm* t = gmtime(&seconds); + char dt[1024]; + sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d", + t->tm_year+1900, t->tm_mon+1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + this->Rev.CommitDate = dt; + + // Add the time-zone field "+zone" or "-zone". + char tz[32]; + if(committer.TimeZone >= 0) + { + sprintf(tz, " +%04ld", committer.TimeZone); + } + else + { + sprintf(tz, " -%04ld", -committer.TimeZone); + } + this->Rev.CommitDate += tz; + } } void DoBodyLine() diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index f9ad79a..fbee227 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -228,6 +228,11 @@ void cmCTestVC::WriteXMLEntry(std::ostream& xml, << "\t\t\t" << cmXMLSafe(rev.Date) << "\n" << "\t\t\t" << cmXMLSafe(rev.Author) << "\n" << "\t\t\t" << cmXMLSafe(rev.EMail) << "\n" + << "\t\t\t" << cmXMLSafe(rev.Committer) << "\n" + << "\t\t\t" << cmXMLSafe(rev.CommitterEMail) + << "\n" + << "\t\t\t" << cmXMLSafe(rev.CommitDate) + << "\n" << "\t\t\t" << cmXMLSafe(rev.Log) << "\n" << "\t\t\t" << cmXMLSafe(rev.Rev) << "\n" << "\t\t\t" << cmXMLSafe(prior) << "\n" diff --git a/Source/CTest/cmCTestVC.h b/Source/CTest/cmCTestVC.h index d36bc8f..44e1dac 100644 --- a/Source/CTest/cmCTestVC.h +++ b/Source/CTest/cmCTestVC.h @@ -74,6 +74,9 @@ protected: std::string Date; std::string Author; std::string EMail; + std::string Committer; + std::string CommitterEMail; + std::string CommitDate; std::string Log; }; -- cgit v0.12 From 59925264829e5c9509f505897aafd33478e80cfe Mon Sep 17 00:00:00 2001 From: Brad King Date: Mon, 20 Dec 2010 17:16:25 -0500 Subject: CTest: Factor out duplicate Git author/committer code Factor out date/time format code into FormatDateTime function instead of duplicating it. --- Source/CTest/cmCTestGIT.cxx | 72 ++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 44 deletions(-) diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 3456ec4..aa9e55b 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -503,28 +503,7 @@ private: this->ParsePerson(this->Line.c_str()+7, author); this->Rev.Author = author.Name; this->Rev.EMail = author.EMail; - - // Convert the time to a human-readable format that is also easy - // to machine-parse: "CCYY-MM-DD hh:mm:ss". - time_t seconds = static_cast(author.Time); - struct tm* t = gmtime(&seconds); - char dt[1024]; - sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d", - t->tm_year+1900, t->tm_mon+1, t->tm_mday, - t->tm_hour, t->tm_min, t->tm_sec); - this->Rev.Date = dt; - - // Add the time-zone field "+zone" or "-zone". - char tz[32]; - if(author.TimeZone >= 0) - { - sprintf(tz, " +%04ld", author.TimeZone); - } - else - { - sprintf(tz, " -%04ld", -author.TimeZone); - } - this->Rev.Date += tz; + this->Rev.Date = this->FormatDateTime(author); } else if(strncmp(this->Line.c_str(), "committer ", 10) == 0) { @@ -532,28 +511,7 @@ private: this->ParsePerson(this->Line.c_str()+10, committer); this->Rev.Committer = committer.Name; this->Rev.CommitterEMail = committer.EMail; - - // Convert the time to a human-readable format that is also easy - // to machine-parse: "CCYY-MM-DD hh:mm:ss". - time_t seconds = static_cast(committer.Time); - struct tm* t = gmtime(&seconds); - char dt[1024]; - sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d", - t->tm_year+1900, t->tm_mon+1, t->tm_mday, - t->tm_hour, t->tm_min, t->tm_sec); - this->Rev.CommitDate = dt; - - // Add the time-zone field "+zone" or "-zone". - char tz[32]; - if(committer.TimeZone >= 0) - { - sprintf(tz, " +%04ld", committer.TimeZone); - } - else - { - sprintf(tz, " -%04ld", -committer.TimeZone); - } - this->Rev.CommitDate += tz; + this->Rev.CommitDate = this->FormatDateTime(committer); } } @@ -566,6 +524,32 @@ private: } this->Rev.Log += "\n"; } + + std::string FormatDateTime(Person const& person) + { + // Convert the time to a human-readable format that is also easy + // to machine-parse: "CCYY-MM-DD hh:mm:ss". + time_t seconds = static_cast(person.Time); + struct tm* t = gmtime(&seconds); + char dt[1024]; + sprintf(dt, "%04d-%02d-%02d %02d:%02d:%02d", + t->tm_year+1900, t->tm_mon+1, t->tm_mday, + t->tm_hour, t->tm_min, t->tm_sec); + std::string out = dt; + + // Add the time-zone field "+zone" or "-zone". + char tz[32]; + if(person.TimeZone >= 0) + { + sprintf(tz, " +%04ld", person.TimeZone); + } + else + { + sprintf(tz, " -%04ld", -person.TimeZone); + } + out += tz; + return out; + } }; char const cmCTestGIT::CommitParser::SectionSep[SectionCount] = -- cgit v0.12