c7d3587df92f36b7d182238cb1d6b8e7dceadbe4 galt Wed Mar 3 02:10:15 2010 -0800 adding html processing diff --git git-reports.c git-reports.c index 9939509..b9cfa87 100644 --- git-reports.c +++ git-reports.c @@ -30,6 +30,7 @@ struct files *next; char type; char *path; + int linesChanged; }; struct commit @@ -174,6 +175,45 @@ return commits; } +int makeHtml(char *diffPath, char *path, char *commitId) +/* Make a color-coded html diff + * Return the number of lines changed */ +{ +int linesChanged = 0; +char *ext = strrchr(diffPath,'.'); +*ext = 0; +char htmlPath[1024]; +safef(htmlPath, sizeof(htmlPath), "%s.html", diffPath); +*ext = '.'; + +FILE *h = mustOpen(htmlPath, "w"); +struct lineFile *lf = lineFileOpen(diffPath, TRUE); +int lineSize; +char *line; +boolean inBody = FALSE; +fprintf(h, "\n
\n\n", path, commitId); +while (lineFileNext(lf, &line, &lineSize)) + { + if (line[0] == '-') + fprintf(h, "%s\n", line); + else if (line[0] == '+') + fprintf(h, "%s\n", line); + else + fprintf(h, "%s\n", line); + + if (line[0] == '@') + inBody = TRUE; + + } + +lineFileClose(&lf); +fprintf(h, "\n