#!/bin/sh # DEBUG #set -e -x usage() { printf '%s \n' "$0" exit 1 } header() { cat < ${description}

${description}

Tree | Log | Stats | README | LICENSE

!__EOF__
}

footer() {
	cat <

Powered by urmoms vibrator
!__EOF__ } if test x"$1" = x"" || test x"$2" = x""; then usage fi # repodir must be a directory to go to. cd "$1" || usage # TODO: make configurable. baseurl="http://cow.codemadness.org/gitlog/" # TODO: read .git/description. description="sbase" # absolute path to logdir. logdir="$(readlink -f $2)" mkdir -p "${logdir}" firstcommit=$(git log | grep '^commit ' | tail -n 1 | cut -f 2 -d ' ') # make log per file. # TODO: just link to commit/commit? save some space and time? git ls-tree -r --name-only master | while read -r file; do test -e "${logdir}/file/${file}.html" && continue d=$(dirname "${file}") mkdir -p "${logdir}/file/${d}" header > "${logdir}/file/${file}.html" git show "${firstcommit}"...master "${file}" | \ sed -E 's@^commit (.*)$@commit \1@g' >> "${logdir}/file/${file}.html" footer >> "${logdir}/file/${file}.html" done # make log with all commits. header > "${logdir}/log.html" printf '' >> "${logdir}/log.html" git log --pretty='' >> "${logdir}/log.html" printf '
%cD%H%an%s
' >> "${logdir}/log.html" footer >> "${logdir}/log.html" # make diff for each commit (all files). mkdir -p "${logdir}/commit" git log --pretty='%H' | while read -r commit; do test -e "${logdir}/commit/${commit}.html" && continue header > "${logdir}/commit/${commit}.html" git show "${commit}" >> "${logdir}/commit/${commit}.html" footer >> "${logdir}/commit/${commit}.html" done # make index with file links. header >> "${logdir}/index.html" git ls-tree -r master | sed -E 's@ (.*)$@ \1@g' >> "${logdir}/index.html" footer >> "${logdir}/index.html" # readme page # find README file. readme="" for f in README README.md readme.md; do test -e "${f}" && readme="${f}" done # make page. header > "${logdir}/readme.html" if test x"${readme}" != x""; then cat "${readme}" >> "${logdir}/readme.html" else echo "no README file found" >> "${logdir}/readme.html" fi footer >> "${logdir}/readme.html" # license page # find LICENSE file. license="" for f in LICENSE LICENSE.md; do test -e "${f}" && license="${f}" done # make page. header > "${logdir}/license.html" if test x"${readme}" != x""; then cat "${license}" >> "${logdir}/license.html" else echo "unknown license" >> "${logdir}/license.html" fi footer >> "${logdir}/license.html" # stats (authors). header > "${logdir}/stats.html" git shortlog -n -s >> "${logdir}/stats.html" footer >> "${logdir}/stats.html"