Commit fa5e232c authored by Claes Sjofors's avatar Claes Sjofors

co_convert function to generate changelog texts from git log

parent 938df603
......@@ -302,7 +302,7 @@ void CnvChangeLog::print_docbook()
sort_time();
fp << "<table xml:id=\"changelog_\" border=\"1\"><tbody>" << endl <<
"<tr><td><classname>Date________</classname></td>" << endl <<
"<tr><td><classname>Date_________</classname></td>" << endl <<
"<td><classname>Module_____</classname></td>" << endl <<
"<td><classname>Change</classname></td></tr>" << endl;
......@@ -376,4 +376,50 @@ void CnvChangeLog::print_html()
"</html>" << endl;
}
void CnvChangeLog::from_git()
{
pwr_tFileName tmpfile = "/tmp/cnv_from_git.txt";
pwr_tCmd cmd = "git log --pretty=format:\"%ai \'%cN\' %s\" >";
char line[1000];
char date[20];
char user[80];
char cuser[80];
char *s1, *s2, *textp = 0;
strcat( cmd, tmpfile);
system( cmd);
ifstream fp( tmpfile);
while( fp.getline( line, sizeof(line))) {
date[0] = line[2];
date[1] = line[3];
date[2] = line[5];
date[3] = line[6];
date[4] = line[8];
date[5] = line[9];
date[6] = 0;
if ( (s1 = strchr( line, '\'')) && (s2 = strchr( s1+1, '\''))) {
*s2 = 0;
strncpy( user, s1 + 1, sizeof(user));
if ( user[0] == 'R' || user[0] == 'r')
strcpy( cuser, "rk");
else
strcpy( cuser, "cs");
textp = s2 + 2;
}
if ( textp)
printf( "%s %s x %s\n", date, cuser, textp);
}
fp.close();
strcpy( cmd, "rm ");
strcat( cmd, tmpfile);
system( cmd);
}
......@@ -102,6 +102,7 @@ class CnvChangeLog {
void sort_module();
void sort_component();
void sort_signature();
static void from_git();
};
#if defined __cplusplus
......
......@@ -83,6 +83,7 @@ static void usage()
printf( " -f: Create pdf from xtthelp-file\n");
printf( " -q: Create postscript from wb_load-files\n");
printf( " -e: Merge changlog files to docbook file\n");
printf( " -i: Convert git log to changelog format\n");
printf( " -a: Create xtthelp from pwg-files\n");
printf( " -d: Output directory\n");
printf( " -g: Setup file\n");
......@@ -123,6 +124,7 @@ int main( int argc, char *argv[])
int xtthelp_to_text = 0;
int pwg_to_xtthelp = 0;
int changelog = 0;
int changelog_from_git = 0;
char from[80] = "";
if ( argc < 2 || argc > 9) {
......@@ -224,6 +226,9 @@ int main( int argc, char *argv[])
case 'e':
changelog = 1;
break;
case 'i':
changelog_from_git = 1;
break;
case '-': {
if ( strcmp( s, "-from") == 0 && ( i+1 < argc)) {
strcpy( from, argv[i+1]);
......@@ -255,6 +260,10 @@ int main( int argc, char *argv[])
delete c;
exit(0);
}
if ( changelog_from_git) {
CnvChangeLog::from_git();
exit(0);
}
if ( xtthelp_to_html) {
CnvXtthelpToHtml *xtthelpto = new CnvXtthelpToHtml( ctx);
ctx->rx = new CnvReadXtthelp( files, ctx->dir, xtthelpto);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment