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%s %s\n\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\n\n"); +fclose(h); + +return linesChanged; +} + + void doUser(char *u, struct commit *commits) /* process one user */ { @@ -201,7 +241,7 @@ } // context unified - safef(path, sizeof(path), "%s/%s/%s/%s/%s/%s.diff", outDir, outPrefix, "user", u, "context", f->path); + safef(path, sizeof(path), "%s/%s/%s/%s/%s/%s%s.diff", outDir, outPrefix, "user", u, "context", f->path, c->commitId); uglyf("path=%s\n", path); safef(gitCmd,sizeof(gitCmd), "" @@ -211,8 +251,10 @@ system(gitCmd); // TODO error handling + int linesChanged = makeHtml(path, f->path, c->commitId); + // full text (up to 10,000 lines) - safef(path, sizeof(path), "%s/%s/%s/%s/%s/%s.diff", outDir, outPrefix, "user", u, "full", f->path); + safef(path, sizeof(path), "%s/%s/%s/%s/%s/%s%s.diff", outDir, outPrefix, "user", u, "full", f->path, c->commitId); uglyf("path=%s\n", path); safef(gitCmd,sizeof(gitCmd), "" @@ -222,6 +264,8 @@ system(gitCmd); // TODO error handling + makeHtml(path, f->path, c->commitId); + //git show --unified=10000 11a20b6cd113d75d84549eb642b7f2ac7a2594fe src/utils/qa/weeklybld/buildEnv.csh @@ -285,6 +329,8 @@ if (!fileExists(path) && mkdir(path, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH) != 0) errnoAbort("unable to mkdir %s", path); + // DEBUG REMOVE + if (sameString(u->name, "galt")) /* make user's reports */ doUser(u->name, commits);