]> git.armaanb.net Git - stagit.git/blobdiff - repo-gen.sh
Ditch linguist and switch to python.
[stagit.git] / repo-gen.sh
index c2a25a81c29ad9cde5b5523cb93847af608e2866..d3440483e8bf5775d3aa23c018d82c7a8e85aab5 100755 (executable)
@@ -1,25 +1,35 @@
 #!/bin/sh
 
 fresh=false
+unique=false
 
 for arg in "$@"; do
+       [ "$unique" = true ]   && unique="$arg"
+       [ "$arg" = "--only" ]  && unique=true
        [ "$arg" = "--fresh" ] && fresh=true
 done
 
+[ "$unique" = true ] && {
+       echo "Expected argument after \`--only\`.";
+       exit 1;
+}
+
 STAGIT=/var/www/git/stagit.out
 [ ! -f "$STAGIT" ] && STAGIT=stagit
 
 STAGIT_INDEX=/var/www/git/stagit-index.out
 [ ! -f "$STAGIT_INDEX" ] && STAGIT_INDEX=stagit-index
 
-for repo in /srv/git/*.git; do
-       repo="$(basename "$repo" | rev | cut -c 5- | rev)"
+build_html () {
+       repo="$1"
+       repo="$(basename "$repo" | sed 's/\.git$//g')"
 
-       [ "$fresh" = true ] \
-               && echo "Deleting HTML for $repo." \
-               && rm -fr "/var/www/git/$repo"
+       [ "$fresh" = true ] && {
+               echo "Deleting HTML for $repo.";
+               rm -fr "/var/www/git/$repo";
+       }
        mkdir -p "/var/www/git/$repo"
-       cd "/var/www/git/$repo"
+       cd "/var/www/git/$repo" || { echo "Couldn't cd."; exit 1; }
 
        [ ! -f style.css ]   && ln -s ../style.css ./
        [ ! -f favicon.png ] && ln -s ../favicon.png ./
@@ -29,9 +39,18 @@ for repo in /srv/git/*.git; do
        echo "git://git.knutsen.co/$repo" > "/srv/git/$repo.git/url"
 
        COMMAND="$STAGIT /srv/git/$repo.git"
+       echo "Building web-page for $repo."
        echo "$COMMAND"
        $COMMAND
-done
+}
+
+if [ "$unique" = false ]; then
+       for repo in /srv/git/*.git; do
+               build_html "$repo"
+       done
+else
+       build_html "$unique"
+fi
 
 echo "Generating index.html with \`$STAGIT_INDEX\`."
 "$STAGIT_INDEX" /srv/git/*.git > /var/www/git/index.html