From 56a95040ca2fe2a265bd27fce365515f7656383e Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sun, 29 Aug 2010 01:44:25 -0300 Subject: [PATCH] Generate commit entry and show diffs also for the first commit. Plus cleanup. - scripts/Makefile: added targets for ben-wpan/cntr - scripts/schhist2web: removed stray and redundant mkdir of output directories - scripts/schhist2web: added section titles - scripts/schhist2web: tag was issued twice per commit - scripts/schhist2web (commit_entry): moved commit entry generation to a separate function - scripts/schhist2web (commit_entry): replaced "git log $next~1..$next" with more robust "git show --quiet $next" - scripts/schhist2web: generate file creation entries for all files in the first commit --- scripts/Makefile | 15 ++++++- scripts/schhist2web | 101 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 96 insertions(+), 20 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index f733f00..5c78a86 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -1,6 +1,8 @@ SHELL = /bin/bash -.PHONY: all ben-wpan-schhist xue-schhist +.PHONY: all ben-wpan-schhist ben-wpan-schhist-upload +.PHONY: xue-schhist xue-schhist-upload +.PHONY: cntr-schhist cntr-schhist-upload # All the targets are for demo purposes pnly ! @@ -8,6 +10,7 @@ all: @echo "possible targets:" 2>&1 @echo " ben-wpan-schhist ben-wpan-schhist-upload" 2>&1 @echo " xue-schhist xue-schhist-upload" 2>&1 + @echo " cntr-schhist cntr-schhist-upload" 2>&1 @exit 1 ben-wpan-schhist: @@ -29,3 +32,13 @@ xue-schhist: xue-schhist-upload: rsync -a --progress _xue/{index.html,unchanged.png,thum*,diff*} \ werner@host:/home/httpd/almesberger/misc/ben/demo2/ + +cntr-schhist: + SCHHIST_TITLE=ben-wpan/cntr \ + SCHHIST_HOME_URL=http://projects.qi-hardware.com/index.php/p/ben-wpan/ \ + SCHHIST_COMMIT_TEMPLATE='http://projects.qi-hardware.com/index.php/p/ben-wpan/source/commit/{}/' \ + ./schhist2web cntr/cntr.sch _cntr + +cntr-schhist-upload: + rsync -a --progress _cntr/{index.html,unchanged.png,thum*,diff*} \ + werner@host:/home/httpd/almesberger/misc/ben/demo3/ diff --git a/scripts/schhist2web b/scripts/schhist2web index c7ef1ec..6000277 100755 --- a/scripts/schhist2web +++ b/scripts/schhist2web @@ -40,6 +40,29 @@ pngdiff() } +commit_entry() +{ + # usage: commit_entry + # note: the repository's base in $dir must be provided by the caller + + local dir=$1 next=$2 + + cat < +EOF + echo "
"
+    ( cd "$dir" && git show --pretty=short --quiet $next; ) |
+      if [ -z "$SCHHIST_COMMIT_TEMPLATE" ]; then
+	cat
+      else
+	url=`echo "$SCHHIST_COMMIT_TEMPLATE" | sed "s/{}/$next/g"`
+	sed "s|^commit |commit |"
+      fi |
+      sed '/^<.*>commit/\>/g'
+    echo "
" +} + + usage() { cat <&1 @@ -56,6 +79,9 @@ EOF } +# --- Parse command-line options ---------------------------------------------- + + no_cache=false sanitize= @@ -73,6 +99,10 @@ while true; do esac done + +# --- Interpret the command-line arguments ------------------------------------ + + if [ ! -z "$1" -a -d "$1/.git" ]; then dir="$1" shift @@ -118,6 +148,10 @@ fi [ -z "$1" ] || usage + +# --- Set up some variables and the directories for cache and output ---------- + + PATH=`dirname "$0"`:"$PATH" first=`gitenealogy "$dir" "$sch" | sed '$s/ .*//p;d'` schname=`gitenealogy "$dir" "$sch" | sed '$s/^.* //p;d'` @@ -127,6 +161,12 @@ $no_cache && rm -rf "$cache" mkdir -p "$out/names" mkdir -p "$cache" +ppmmake '#e0e0e0' 5 30 | pnmtopng >"$out"/unchanged.png + + +# --- Generate/update the cache ----------------------------------------------- + + head= for n in $first `cd "$dir" && git rev-list --reverse $first..HEAD`; do ( cd "$dir" && git show --pretty=format:'' --name-only $n; ) | @@ -157,7 +197,9 @@ if [ -z "$head" ]; then exit 1 fi -ppmmake '#e0e0e0' 5 30 | pnmtopng >"$out"/unchanged.png + +# --- Title of the Web page and table header ---------------------------------- + index="$out/index.html" { @@ -185,11 +227,15 @@ EOF done } >"$index" + +# --- Diff all the revisions, newest to oldest -------------------------------- + + next="$head" for n in `cd "$dir" && git rev-list $first..HEAD~1` $first; do [ -d "$cache/ppm_$n" ] || continue empty=true - s="" + s="" mkdir -p "$out/diff_$next" "$out/thumb_$next" for m in `ls -1 "$out/names"`; do a="$cache/ppm_$n/$m.ppm" @@ -227,27 +273,44 @@ for n in `cd "$dir" && git rev-list $first..HEAD~1` $first; do echo "" >>"$index" done if ! $empty; then - ( - cat < -
-EOF - mkdir -p "$out/diff_$next" "$out/thumb_$next" - echo "
"
-	    ( cd "$dir" && git log --pretty=short $next~1..$next; ) |
-	      if [ -z "$SCHHIST_COMMIT_TEMPLATE" ]; then
-		cat
-	      else
-		url=`echo "$SCHHIST_COMMIT_TEMPLATE" | sed "s/{}/$next/g"`
-		sed "s|^commit |commit |"
-	      fi |
-	      sed '/^<.*>commit/\>/g'
-	    echo "
" - ) >>"$index" + echo "$s" >>"$index" + commit_entry "$dir" $next >>"$index" fi next=$n done + +# --- Add creation entries for all files in the first commit ------------------ + + +if [ -d "$cache/ppm_$next" ]; then # could this ever be false ? + empty=true + echo "" >>"$index" + mkdir -p "$out/diff_$next" "$out/thumb_$next" + for m in `ls -1 "$out/names"`; do + ppm="$cache/ppm_$next/$m.ppm" + fat="$cache/fat_$next/$m.ppm" + diff="$out/diff_$next/$m.png" + thumb="$out/thumb_$next/$m.png" + + echo "" >>"$index" + [ -f "$ppm" ] || continue + pngdiff cat "$diff" -f -c 0,1,0 "$ppm" "$ppm" || exit + pngdiff shrink "$thumb" -f $THUMB_OPTS -c 0,1,0 "$fat" "$fat" \ + || exit + empty=false + echo "" >>"$index" + done + if ! $empty; then + echo "" >>"$index" + commit_entry "$dir" $next >>"$index" + fi +fi + + +# --- Finish ------------------------------------------------------------------ + + cat <>"$index"