From d7d95ff2da07c37cd95d5466d7cd2b775c771ec8 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Fri, 27 Aug 2010 19:32:52 -0300 Subject: [PATCH] Allow schhist2web and friends to run from a directory outside the working tree. - scripts/gitenealogy: now requires the repository directory to be passed - scripts/schhist2web: adapted for above change - scripts/schhist2web: change to the repository's directory before each call to git - scripts/Makefile: added demo upload and Xue build - scripts/Makefile (all): added usage information --- scripts/Makefile | 24 +++++++++++++++++++++++- scripts/gitenealogy | 23 +++++++++++++++++++---- scripts/schhist2web | 14 +++++++------- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/scripts/Makefile b/scripts/Makefile index 4c4d6a7..a9cc249 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -1,9 +1,31 @@ -.PHONY: all ben-wpan-schhist +SHELL = /bin/bash + +.PHONY: all ben-wpan-schhist xue-schhist + +# All the targets are for demo purposes pnly ! all: + @echo "possible targets:" 2>&1 + @echo " ben-wpan-schhist ben-wpan-schhist-upload" 2>&1 + @echo " xue-schhist xue-schhist-upload" 2>&1 + @exit 1 ben-wpan-schhist: SCHHIST_TITLE=ben-wpan/atrf \ 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 atrf/wpan-atrf.sch + +ben-wpan-schhist-upload: + rsync -a --progress _out/{index.html,unchanged.png,thum*,diff*} \ + werner@host:/home/httpd/almesberger/misc/ben/demo/ + +xue-schhist: + SCHHIST_TITLE=Xue \ + SCHHIST_HOME_URL=http://projects.qi-hardware.com/index.php/p/xue/ \ + SCHHIST_COMMIT_TEMPLATE='http://projects.qi-hardware.com/index.php/p/xue/source/commit/{}/' \ + ./schhist2web ../../xue kicad/xue-rnc/xue-rnc.sch _xue + +xue-schhist-upload: + rsync -a --progress _xue/{index.html,unchanged.png,thum*,diff*} \ + werner@host:/home/httpd/almesberger/misc/ben/demo2/ diff --git a/scripts/gitenealogy b/scripts/gitenealogy index aa49bb7..d129070 100755 --- a/scripts/gitenealogy +++ b/scripts/gitenealogy @@ -14,15 +14,30 @@ usage() { - echo "usage: $0 path" 2>&1 + cat <&1 +usage: $0 repo-dir path + + The file to trace must be at repo-dir/path +EOF exit 1 } -[ -z "$1" -o ! -z "$2" ] && usage -[ ! -f "$1" ] && usage +if [ -z "$2" -o ! -z "$3" ]; then + usage +fi -git log --follow --name-status "$1" | +if [ ! -d "$1" -o ! -d "$1/.git" ]; then + echo "no git repository at $1" 1>&2 + exit 1 +fi +if [ ! -f "$1/$2" ]; then + echo "cannot find $2" 2>&1 + exit 1 +fi + +cd "$1" || exit +git log --follow --name-status "$2" | awk ' /^commit /{ if (c) print c, n; c = $2 } { if (NF) n = $(NF) } diff --git a/scripts/schhist2web b/scripts/schhist2web index 9fb7019..48d3474 100755 --- a/scripts/schhist2web +++ b/scripts/schhist2web @@ -114,8 +114,8 @@ fi [ -z "$1" ] || usage PATH=`dirname "$0"`:"$PATH" -first=`gitenealogy "$dir/$sch" | sed '$s/ .*//p;d'` -schname=`gitenealogy "$dir/$sch" | sed '$s/^.* //p;d'` +first=`gitenealogy "$dir" "$sch" | sed '$s/ .*//p;d'` +schname=`gitenealogy "$dir" "$sch" | sed '$s/^.* //p;d'` rm -rf "$out/diff_*" "$out/thumb_*" "$out/names" $no_cache && rm -rf "$cache" @@ -123,11 +123,11 @@ mkdir -p "$out/names" mkdir -p "$cache" head= -for n in $first `git rev-list --reverse $first..HEAD`; do - git show --pretty=format:'' --name-only $n | +for n in $first `cd "$dir" && git rev-list --reverse $first..HEAD`; do + ( cd "$dir" && git show --pretty=format:'' --name-only $n; ) | egrep -q '\.sch$|\.pro$|\.lib$' || continue echo Processing $n - new=`gitenealogy "$dir/$sch" | sed "/^$n /s///p;d"` + new=`gitenealogy "$dir" "$sch" | sed "/^$n /s///p;d"` if [ ! -z "$new" ]; then echo Name change $schname to $new 1>&2 schname="$new" @@ -181,7 +181,7 @@ EOF } >"$index" next="$head" -for n in `git rev-list $first..HEAD~1` $first; do +for n in `cd "$dir" && git rev-list $first..HEAD~1` $first; do [ -d "$cache/ppm_$n" ] || continue empty=true s="" @@ -229,7 +229,7 @@ $s EOF mkdir -p "$out/diff_$next" "$out/thumb_$next" echo "
"
-	    git log --pretty=short $next~1..$next |
+	    ( cd "$dir" && git log --pretty=short $next~1..$next; ) |
 	      if [ -z "$SCHHIST_COMMIT_TEMPLATE" ]; then
 		cat
 	      else