]> git.armaanb.net Git - stagit.git/commitdiff
improve example scripts, add to build (Makefile)
authorHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 30 Jul 2017 15:21:42 +0000 (17:21 +0200)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Sun, 30 Jul 2017 15:21:42 +0000 (17:21 +0200)
Makefile
README
example.sh [deleted file]
example_create.sh [new file with mode: 0644]
example_post-receive.sh

index b4ea03c58762cb711773a7cff493e10cf048fef2..2423dda2fea2b75bae3b4cb37aee284b16c84da8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -40,7 +40,7 @@ dist:
        mkdir -p ${NAME}-${VERSION}
        cp -f ${MAN1} ${HDR} ${SCRIPTS} ${SRC} ${COMPATSRC} ${DOC} \
                Makefile config.mk favicon.png logo.png style.css \
-               example.sh \
+               example_create.sh example_post-receive.sh \
                ${NAME}-${VERSION}
        # make tarball
        tar -cf - ${NAME}-${VERSION} | \
@@ -68,7 +68,8 @@ install: all
        cp -f style.css\
                favicon.png\
                logo.png\
-               example.sh\
+               example_create.sh\
+               example_post-receive.sh\
                README\
                ${DESTDIR}${PREFIX}/share/${NAME}
        # installing manual pages.
@@ -84,7 +85,8 @@ uninstall:
                ${DESTDIR}${PREFIX}/share/${NAME}/style.css\
                ${DESTDIR}${PREFIX}/share/${NAME}/favicon.png\
                ${DESTDIR}${PREFIX}/share/${NAME}/logo.png\
-               ${DESTDIR}${PREFIX}/share/${NAME}/example.sh\
+               ${DESTDIR}${PREFIX}/share/${NAME}/example_create.sh\
+               ${DESTDIR}${PREFIX}/share/${NAME}/example_post-receive.sh\
                ${DESTDIR}${PREFIX}/share/${NAME}/README
        -rmdir ${DESTDIR}${PREFIX}/share/${NAME}
        # removing manual pages.
diff --git a/README b/README
index 36e13ac8349862982d40149b6986dfbabe8e45ee..c3eea1a083d50da8f57028752962c4051f881e51 100644 (file)
--- a/README
+++ b/README
@@ -114,7 +114,7 @@ git post-receive hook (repo/.git/hooks/post-receive):
        # ...
        #fi
 
-       # see example.sh for normal creation of the files.
+       # see example_create.sh for normal creation of the files.
 
 
 Create .tar.gz archives by tag
diff --git a/example.sh b/example.sh
deleted file mode 100644 (file)
index 57290d3..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-#!/bin/sh
-# - Makes index for repositories in a single directory.
-# - Makes static pages for each repository directory.
-#
-# NOTE, things to do manually (once) before running this script:
-# - copy style.css, logo.png and favicon.png manually, a style.css example
-#   is included.
-#
-# - write clone url, for example "git://git.codemadness.org/dir" to the "url"
-#   file for each repo.
-# - write owner of repo to the "owner" file.
-# - write description in "description" file.
-#
-# Usage:
-# - mkdir -p htmldir && cd htmldir
-# - sh example.sh
-
-# path must be absolute.
-reposdir="/var/www/domains/git.codemadness.nl/home/src"
-curdir=$(pwd)
-
-# make index.
-stagit-index "${reposdir}/"*/ > "${curdir}/index.html"
-
-# make files per repo.
-for dir in "${reposdir}/"*/; do
-       # strip .git suffix.
-       r=$(basename "${dir}")
-       d=$(basename "${dir}" ".git")
-       printf "%s... " "${d}"
-
-       mkdir -p "${curdir}/${d}"
-       cd "${curdir}/${d}"
-       stagit -c ".cache" "${reposdir}/${r}"
-
-       # symlinks
-       ln -sf log.html index.html
-       ln -sf ../style.css style.css
-       ln -sf ../logo.png logo.png
-       ln -sf ../favicon.png favicon.png
-
-       printf "done\n"
-done
diff --git a/example_create.sh b/example_create.sh
new file mode 100644 (file)
index 0000000..aff7d54
--- /dev/null
@@ -0,0 +1,43 @@
+#!/bin/sh
+# - Makes index for repositories in a single directory.
+# - Makes static pages for each repository directory.
+#
+# NOTE, things to do manually (once) before running this script:
+# - copy style.css, logo.png and favicon.png manually, a style.css example
+#   is included.
+#
+# - write clone url, for example "git://git.codemadness.org/dir" to the "url"
+#   file for each repo.
+# - write owner of repo to the "owner" file.
+# - write description in "description" file.
+#
+# Usage:
+# - mkdir -p htmldir && cd htmldir
+# - sh example_create.sh
+
+# path must be absolute.
+reposdir="/var/www/domains/git.codemadness.nl/home/src"
+curdir="$(pwd)"
+
+# make index.
+stagit-index "${reposdir}/"*/ > "${curdir}/index.html"
+
+# make files per repo.
+for dir in "${reposdir}/"*/; do
+       # strip .git suffix.
+       r=$(basename "${dir}")
+       d=$(basename "${dir}" ".git")
+       printf "%s... " "${d}"
+
+       mkdir -p "${curdir}/${d}"
+       cd "${curdir}/${d}"
+       stagit -c ".cache" "${reposdir}/${r}"
+
+       # symlinks
+       ln -sf log.html index.html
+       ln -sf ../style.css style.css
+       ln -sf ../logo.png logo.png
+       ln -sf ../favicon.png favicon.png
+
+       echo "done"
+done
index 38bda4932ee2da639075aac5e3b199644459b4ae..5f827e109da42361bf00d4fbba7af00538f7701e 100755 (executable)
@@ -9,8 +9,8 @@
 # this is the directory of the repo when called from the post-receive script.
 
 name="$1"
-if test "$name" = ""; then
-       name="$(basename $(pwd))"
+if test "${name}" = ""; then
+       name=$(basename $(pwd))
 fi
 
 # config
@@ -23,17 +23,17 @@ destdir="${htmldir}${stagitdir}"
 cachefile=".htmlcache"
 # /config
 
-if ! test -d "$dir"; then
-       echo "$dir does not exist" >&2
+if ! test -d "${dir}"; then
+       echo "${dir} does not exist" >&2
        exit 1
 fi
-cd "$dir" || exit 1
+cd "${dir}" || exit 1
 
 # detect git push -f
 force=0
 while read -r old new ref; do
-       hasrevs=$(git rev-list "$old" "^$new" | sed 1q)
-       if test -n "$hasrevs"; then
+       hasrevs=$(git rev-list "${old}" "^${new}" | sed 1q)
+       if test -n "${hasrevs}"; then
                force=1
                break
        fi
@@ -47,14 +47,15 @@ printf "[%s] stagit HTML pages... " "${d}"
 mkdir -p "${destdir}/${d}"
 cd "${destdir}/${d}" || exit 1
 
-# remove commits and $cachefile on git push -f, this recreated later on.
-if test "$force" = "1"; then
+# remove commits and ${cachefile} on git push -f, this recreated later on.
+if test "${force}" = "1"; then
        rm -f "${cachefile}"
        rm -rf "commit"
 fi
 
 # make index.
 stagit-index "${reposdir}/"*/ > "${destdir}/index.html"
+
 # make pages.
 stagit -c "${cachefile}" "${reposdir}/${r}"
 
@@ -62,4 +63,4 @@ ln -sf log.html index.html
 ln -sf ../style.css style.css
 ln -sf ../logo.png logo.png
 
-printf "done\n"
+echo "done"