example scripts: fix prefix path for index, style consistency for variable names - stagit-gopher - A git gopher frontend. (mirror)
 (HTM) git clone git://bitreich.org/stagit-gopher/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/stagit-gopher/
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) Tags
 (DIR) README
 (DIR) LICENSE
       ---
 (DIR) commit b2cff63407161b2d5de03d8bb086e88a346d649d
 (DIR) parent ae93933e10045242a9e19f49a6f8499323faf7f0
 (HTM) Author: Hiltjo Posthuma <hiltjo@codemadness.org>
       Date:   Sun, 30 Jul 2017 17:14:09 +0200
       
       example scripts: fix prefix path for index, style consistency for variable names
       
       Diffstat:
         M example_create.sh                   |       2 +-
         M example_post-receive.sh             |      25 +++++++++++++------------
       
       2 files changed, 14 insertions(+), 13 deletions(-)
       ---
 (DIR) diff --git a/example_create.sh b/example_create.sh
       @@ -34,5 +34,5 @@ for dir in "${reposdir}/"*/; do
                # symlinks
                ln -sf log.gph index.gph
        
       -        printf "done\n"
       +        echo "done"
        done
 (DIR) diff --git a/example_post-receive.sh b/example_post-receive.sh
       @@ -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="${gopherdir}/${stagitdir}"
        cachefile=".gphcache"
        # /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,20 +47,21 @@ printf "[%s] stagit .gph 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
        
       +# remove /'s at the end.
       +stagitdir=$(printf "%s" "${stagitdir}" | sed "s@[/]*$@@g")
       +
        # make index.
        stagit-gopher-index -b "${stagitdir}" "${reposdir}/"*/ > "${destdir}/index.gph"
        
       -# remove /'s at the end.
       -stagitdir=$(printf '%s' "${stagitdir}" | sed 's@[/]*$@@g')
        # make pages.
        stagit-gopher -b "${stagitdir}/${d}" -c "${cachefile}" "${reposdir}/${r}"
        
        ln -sf log.gph index.gph
        
       -printf "done\n"
       +echo "done"