]> git.armaanb.net Git - stagit.git/commitdiff
example.sh: add index-time.html, list sorted by time, fix reposdir '/'
authorHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 8 Jan 2016 12:39:23 +0000 (13:39 +0100)
committerHiltjo Posthuma <hiltjo@codemadness.org>
Fri, 8 Jan 2016 12:44:22 +0000 (13:44 +0100)
example.sh

index 1824dc3b99f8c5cc61f942f0b6e1287c67fa9610..385283d272c9b889ce8bdf484a29e22a0bfe6db4 100644 (file)
 
 set -e
 
-reposdir="/var/www/domains/git.codemadness.nl/home/src/"
+reposdir="/var/www/domains/git.codemadness.nl/home/src"
 curdir=$(pwd)
 
 # make index.
 cd "${reposdir}"
-find . -maxdepth 1 -type d | grep -v "^.$" | sort | xargs stagit-index > "${curdir}/index.html"
+find . -maxdepth 1 -type d | grep -v "^.$" | sort | xargs stagit-index |
+        sed 's@<td>Last commit</td>@<td><a href="index-time.html">Last commit</a></td>@g' | \
+        sed 's@<td>Name</td>@<td><a href="index.html">Name</a></td>@g' > "${curdir}/index.html"
+
+# make index (sort by last commit author time).
+find . -maxdepth 1 -type d | grep -v "^.$" | while read -r dir; do
+       d=$(basename "${dir}")
+       cd "${reposdir}/${d}"
+       timestamp=$(git show -s --pretty="format:%at" || true)
+
+       printf "%d %s\n" "${timestamp}" "${d}"
+done | sort -n -k 1 | cut -f 2- -d ' ' | xargs stagit-index | \
+       sed 's@<td>Last commit</td>@<td><a href="index-time.html">Last commit</a></td>@g' | \
+       sed 's@<td>Name</td>@<td><a href="index.html">Name</a></td>@g' > "${curdir}/index-time.html"
 
 # make files per repo.
 find . -maxdepth 1 -type d | grep -v "^.$" | sort | while read -r dir; do
-       cd "${reposdir}"
        d=$(basename "${dir}")
 
        printf "%s..." "${d}"
@@ -31,7 +43,7 @@ find . -maxdepth 1 -type d | grep -v "^.$" | sort | while read -r dir; do
 
        test -d "${d}" || mkdir -p "${d}"
        cd "${d}"
-       stagit "${reposdir}${d}"
+       stagit "${reposdir}/${d}"
 
        printf " done\n"