Date:2010-08-29 06:44:25 (8 years 10 months ago)
Author:Werner Almesberger
Commit:56a95040ca2fe2a265bd27fce365515f7656383e
Message: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: <TR> 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
Files: scripts/Makefile (3 diffs)
scripts/schhist2web (8 diffs)

Change Details

scripts/Makefile
11SHELL = /bin/bash
22
3.PHONY: all ben-wpan-schhist xue-schhist
3.PHONY: all ben-wpan-schhist ben-wpan-schhist-upload
4.PHONY: xue-schhist xue-schhist-upload
5.PHONY: cntr-schhist cntr-schhist-upload
46
57# All the targets are for demo purposes pnly !
68
...... 
810        @echo "possible targets:" 2>&1
911        @echo " ben-wpan-schhist ben-wpan-schhist-upload" 2>&1
1012        @echo " xue-schhist xue-schhist-upload" 2>&1
13        @echo " cntr-schhist cntr-schhist-upload" 2>&1
1114        @exit 1
1215
1316ben-wpan-schhist:
...... 
2932xue-schhist-upload:
3033     rsync -a --progress _xue/{index.html,unchanged.png,thum*,diff*} \
3134       werner@host:/home/httpd/almesberger/misc/ben/demo2/
35
36cntr-schhist:
37    SCHHIST_TITLE=ben-wpan/cntr \
38      SCHHIST_HOME_URL=http://projects.qi-hardware.com/index.php/p/ben-wpan/ \
39      SCHHIST_COMMIT_TEMPLATE='http://projects.qi-hardware.com/index.php/p/ben-wpan/source/commit/{}/' \
40      ./schhist2web cntr/cntr.sch _cntr
41
42cntr-schhist-upload:
43     rsync -a --progress _cntr/{index.html,unchanged.png,thum*,diff*} \
44       werner@host:/home/httpd/almesberger/misc/ben/demo3/
scripts/schhist2web
4040}
4141
4242
43commit_entry()
44{
45    # usage: commit_entry <base-dir> <commit>
46    # note: the repository's base in $dir must be provided by the caller
47
48    local dir=$1 next=$2
49
50    cat <<EOF
51<TABLE bgcolor="$SEP_COLOR" cellspacing=0 width="100%"><TR><TD></TABLE>
52EOF
53    echo "<PRE>"
54    ( cd "$dir" && git show --pretty=short --quiet $next; ) |
55      if [ -z "$SCHHIST_COMMIT_TEMPLATE" ]; then
56    cat
57      else
58    url=`echo "$SCHHIST_COMMIT_TEMPLATE" | sed "s/{}/$next/g"`
59    sed "s|^commit |<A href=\"$url\">commit</a> |"
60      fi |
61      sed '/^<.*>commit</n;s/&/&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
62    echo "</PRE>"
63}
64
65
4366usage()
4467{
4568    cat <<EOF 2>&1
...... 
5679}
5780
5881
82# --- Parse command-line options ----------------------------------------------
83
84
5985no_cache=false
6086sanitize=
6187
...... 
7399    esac
74100done
75101
102
103# --- Interpret the command-line arguments ------------------------------------
104
105
76106if [ ! -z "$1" -a -d "$1/.git" ]; then
77107    dir="$1"
78108    shift
...... 
118148
119149[ -z "$1" ] || usage
120150
151
152# --- Set up some variables and the directories for cache and output ----------
153
154
121155PATH=`dirname "$0"`:"$PATH"
122156first=`gitenealogy "$dir" "$sch" | sed '$s/ .*//p;d'`
123157schname=`gitenealogy "$dir" "$sch" | sed '$s/^.* //p;d'`
...... 
127161mkdir -p "$out/names"
128162mkdir -p "$cache"
129163
164ppmmake '#e0e0e0' 5 30 | pnmtopng >"$out"/unchanged.png
165
166
167# --- Generate/update the cache -----------------------------------------------
168
169
130170head=
131171for n in $first `cd "$dir" && git rev-list --reverse $first..HEAD`; do
132172    ( cd "$dir" && git show --pretty=format:'' --name-only $n; ) |
...... 
157197    exit 1
158198fi
159199
160ppmmake '#e0e0e0' 5 30 | pnmtopng >"$out"/unchanged.png
200
201# --- Title of the Web page and table header ----------------------------------
202
161203
162204index="$out/index.html"
163205{
...... 
185227    done
186228} >"$index"
187229
230
231# --- Diff all the revisions, newest to oldest --------------------------------
232
233
188234next="$head"
189235for n in `cd "$dir" && git rev-list $first..HEAD~1` $first; do
190236    [ -d "$cache/ppm_$n" ] || continue
191237    empty=true
192    s="<TR><TR>"
238    s="<TR>"
193239    mkdir -p "$out/diff_$next" "$out/thumb_$next"
194240    for m in `ls -1 "$out/names"`; do
195241    a="$cache/ppm_$n/$m.ppm"
...... 
227273    echo "<A href=\"diff_$next/$m.png\"><IMG src=\"thumb_$next/$m.png\"></A>" >>"$index"
228274    done
229275    if ! $empty; then
230    (
231        cat <<EOF
232$s<TD valign="middle">
233<TABLE bgcolor="$SEP_COLOR" cellspacing=0 width="100%"><TR><TD></TABLE>
234EOF
235    mkdir -p "$out/diff_$next" "$out/thumb_$next"
236        echo "<PRE>"
237        ( cd "$dir" && git log --pretty=short $next~1..$next; ) |
238          if [ -z "$SCHHIST_COMMIT_TEMPLATE" ]; then
239        cat
240          else
241        url=`echo "$SCHHIST_COMMIT_TEMPLATE" | sed "s/{}/$next/g"`
242        sed "s|^commit |<A href=\"$url\">commit</a> |"
243          fi |
244          sed '/^<.*>commit</n;s/&/&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
245        echo "</PRE>"
246    ) >>"$index"
276     echo "$s<TD valign=\"middle\">" >>"$index"
277    commit_entry "$dir" $next >>"$index"
247278    fi
248279    next=$n
249280done
250281
282
283# --- Add creation entries for all files in the first commit ------------------
284
285
286if [ -d "$cache/ppm_$next" ]; then # could this ever be false ?
287    empty=true
288    echo "<TR>" >>"$index"
289    mkdir -p "$out/diff_$next" "$out/thumb_$next"
290    for m in `ls -1 "$out/names"`; do
291    ppm="$cache/ppm_$next/$m.ppm"
292    fat="$cache/fat_$next/$m.ppm"
293    diff="$out/diff_$next/$m.png"
294    thumb="$out/thumb_$next/$m.png"
295
296    echo "<TD>" >>"$index"
297    [ -f "$ppm" ] || continue
298    pngdiff cat "$diff" -f -c 0,1,0 "$ppm" "$ppm" || exit
299    pngdiff shrink "$thumb" -f $THUMB_OPTS -c 0,1,0 "$fat" "$fat" \
300          || exit
301    empty=false
302    echo "<A href=\"diff_$next/$m.png\"><IMG src=\"thumb_$next/$m.png\"></A>" >>"$index"
303    done
304    if ! $empty; then
305     echo "<TD valign=\"middle\">" >>"$index"
306    commit_entry "$dir" $next >>"$index"
307    fi
308fi
309
310
311# --- Finish ------------------------------------------------------------------
312
313
251314cat <<EOF >>"$index"
252315</TABLE>
253316<HR>

Archive Download the corresponding diff file



interactive