stagit

improve example scripts, add to build (Makefile)

Hiltjo Posthuma contact@arjunchoudhary.com

commit: 028b736 parent: bebce68
4 files changed, 20 insertions(+), 17 deletions(-)
MMakefile+5-3
MREADME+1-1
Rexample_create.sh+3-3
Mexample_post-receive.sh+11-10
M · Makefile +5, -3
 1@@ -40,7 +40,7 @@ dist:
 2 	mkdir -p ${NAME}-${VERSION}
 3 	cp -f ${MAN1} ${HDR} ${SCRIPTS} ${SRC} ${COMPATSRC} ${DOC} \
 4 		Makefile config.mk favicon.png logo.png style.css \
 5-		example.sh \
 6+		example_create.sh example_post-receive.sh \
 7 		${NAME}-${VERSION}
 8 	# make tarball
 9 	tar -cf - ${NAME}-${VERSION} | \
10@@ -68,7 +68,8 @@ install: all
11 	cp -f style.css\
12 		favicon.png\
13 		logo.png\
14-		example.sh\
15+		example_create.sh\
16+		example_post-receive.sh\
17 		README\
18 		${DESTDIR}${PREFIX}/share/${NAME}
19 	# installing manual pages.
20@@ -84,7 +85,8 @@ uninstall:
21 		${DESTDIR}${PREFIX}/share/${NAME}/style.css\
22 		${DESTDIR}${PREFIX}/share/${NAME}/favicon.png\
23 		${DESTDIR}${PREFIX}/share/${NAME}/logo.png\
24-		${DESTDIR}${PREFIX}/share/${NAME}/example.sh\
25+		${DESTDIR}${PREFIX}/share/${NAME}/example_create.sh\
26+		${DESTDIR}${PREFIX}/share/${NAME}/example_post-receive.sh\
27 		${DESTDIR}${PREFIX}/share/${NAME}/README
28 	-rmdir ${DESTDIR}${PREFIX}/share/${NAME}
29 	# removing manual pages.
M · README +1, -1
1@@ -114,7 +114,7 @@ git post-receive hook (repo/.git/hooks/post-receive):
2 	# ...
3 	#fi
4 
5-	# see example.sh for normal creation of the files.
6+	# see example_create.sh for normal creation of the files.
7 
8 
9 Create .tar.gz archives by tag
R example.sh=>· example_create.sh +3, -3
 1@@ -13,11 +13,11 @@
 2 #
 3 # Usage:
 4 # - mkdir -p htmldir && cd htmldir
 5-# - sh example.sh
 6+# - sh example_create.sh
 7 
 8 # path must be absolute.
 9 reposdir="/var/www/domains/git.codemadness.nl/home/src"
10-curdir=$(pwd)
11+curdir="$(pwd)"
12 
13 # make index.
14 stagit-index "${reposdir}/"*/ > "${curdir}/index.html"
15@@ -39,5 +39,5 @@ for dir in "${reposdir}/"*/; do
16 	ln -sf ../logo.png logo.png
17 	ln -sf ../favicon.png favicon.png
18 
19-	printf "done\n"
20+	echo "done"
21 done
M · example_post-receive.sh +11, -10
 1@@ -9,8 +9,8 @@
 2 # this is the directory of the repo when called from the post-receive script.
 3 
 4 name="$1"
 5-if test "$name" = ""; then
 6-	name="$(basename $(pwd))"
 7+if test "${name}" = ""; then
 8+	name=$(basename $(pwd))
 9 fi
10 
11 # config
12@@ -23,17 +23,17 @@ destdir="${htmldir}${stagitdir}"
13 cachefile=".htmlcache"
14 # /config
15 
16-if ! test -d "$dir"; then
17-	echo "$dir does not exist" >&2
18+if ! test -d "${dir}"; then
19+	echo "${dir} does not exist" >&2
20 	exit 1
21 fi
22-cd "$dir" || exit 1
23+cd "${dir}" || exit 1
24 
25 # detect git push -f
26 force=0
27 while read -r old new ref; do
28-	hasrevs=$(git rev-list "$old" "^$new" | sed 1q)
29-	if test -n "$hasrevs"; then
30+	hasrevs=$(git rev-list "${old}" "^${new}" | sed 1q)
31+	if test -n "${hasrevs}"; then
32 		force=1
33 		break
34 	fi
35@@ -47,14 +47,15 @@ printf "[%s] stagit HTML pages... " "${d}"
36 mkdir -p "${destdir}/${d}"
37 cd "${destdir}/${d}" || exit 1
38 
39-# remove commits and $cachefile on git push -f, this recreated later on.
40-if test "$force" = "1"; then
41+# remove commits and ${cachefile} on git push -f, this recreated later on.
42+if test "${force}" = "1"; then
43 	rm -f "${cachefile}"
44 	rm -rf "commit"
45 fi
46 
47 # make index.
48 stagit-index "${reposdir}/"*/ > "${destdir}/index.html"
49+
50 # make pages.
51 stagit -c "${cachefile}" "${reposdir}/${r}"
52 
53@@ -62,4 +63,4 @@ ln -sf log.html index.html
54 ln -sf ../style.css style.css
55 ln -sf ../logo.png logo.png
56 
57-printf "done\n"
58+echo "done"