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

${name}

${description}
Log | Files | Stats | README | LICENSE

!__EOF__
}

footer() {
	cat <

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