1
0
mirror of git://projects.qi-hardware.com/ben-wpan.git synced 2024-12-23 09:32:27 +02:00

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
This commit is contained in:
Werner Almesberger 2010-08-29 01:44:25 -03:00
parent 3ca646cd57
commit 56a95040ca
2 changed files with 96 additions and 20 deletions

View File

@ -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/

View File

@ -40,6 +40,29 @@ pngdiff()
}
commit_entry()
{
# usage: commit_entry <base-dir> <commit>
# note: the repository's base in $dir must be provided by the caller
local dir=$1 next=$2
cat <<EOF
<TABLE bgcolor="$SEP_COLOR" cellspacing=0 width="100%"><TR><TD></TABLE>
EOF
echo "<PRE>"
( 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 |<A href=\"$url\">commit</a> |"
fi |
sed '/^<.*>commit</n;s/&/&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
echo "</PRE>"
}
usage()
{
cat <<EOF 2>&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="<TR><TR>"
s="<TR>"
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 "<A href=\"diff_$next/$m.png\"><IMG src=\"thumb_$next/$m.png\"></A>" >>"$index"
done
if ! $empty; then
(
cat <<EOF
$s<TD valign="middle">
<TABLE bgcolor="$SEP_COLOR" cellspacing=0 width="100%"><TR><TD></TABLE>
EOF
mkdir -p "$out/diff_$next" "$out/thumb_$next"
echo "<PRE>"
( 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 |<A href=\"$url\">commit</a> |"
fi |
sed '/^<.*>commit</n;s/&/&amp;/g;s/</\&lt;/g;s/>/\&gt;/g'
echo "</PRE>"
) >>"$index"
echo "$s<TD valign=\"middle\">" >>"$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 "<TR>" >>"$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 "<TD>" >>"$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 "<A href=\"diff_$next/$m.png\"><IMG src=\"thumb_$next/$m.png\"></A>" >>"$index"
done
if ! $empty; then
echo "<TD valign=\"middle\">" >>"$index"
commit_entry "$dir" $next >>"$index"
fi
fi
# --- Finish ------------------------------------------------------------------
cat <<EOF >>"$index"
</TABLE>
<HR>