2015-12-04 15:58:04 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# DEBUG
|
|
|
|
#set -e -x
|
|
|
|
|
2015-12-04 16:11:24 +00:00
|
|
|
usage() {
|
|
|
|
printf '%s <repodir> <htmldir>\n' "$0"
|
|
|
|
exit 1
|
|
|
|
}
|
2015-12-04 15:58:04 +00:00
|
|
|
|
|
|
|
header() {
|
|
|
|
cat <<!__EOF__
|
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html dir="ltr" lang="en">
|
|
|
|
<head>
|
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
|
|
|
|
<meta http-equiv="Content-Language" content="en" />
|
2015-12-04 16:26:39 +00:00
|
|
|
<title>${name} - ${description}</title>
|
2015-12-04 15:58:04 +00:00
|
|
|
<base href="${baseurl}" />
|
|
|
|
<link rel="stylesheet" type="text/css" href="style.css" />
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<center>
|
2015-12-04 16:26:39 +00:00
|
|
|
<h1><img src="logo.png" alt="" /> ${name}</h1>
|
|
|
|
<span class="desc">${description}</span><br/>
|
2015-12-04 15:58:04 +00:00
|
|
|
<a href="log.html">Log</a> |
|
2015-12-04 16:26:39 +00:00
|
|
|
<a href="files.html">Files</a> |
|
2015-12-04 15:58:04 +00:00
|
|
|
<a href="stats.html">Stats</a> |
|
|
|
|
<a href="readme.html">README</a> |
|
|
|
|
<a href="license.html">LICENSE</a>
|
|
|
|
</center>
|
|
|
|
<hr/>
|
|
|
|
<pre>
|
|
|
|
!__EOF__
|
|
|
|
}
|
|
|
|
|
|
|
|
footer() {
|
|
|
|
cat <<!__EOF__
|
|
|
|
</pre>
|
|
|
|
<hr/>
|
|
|
|
<i><center>Powered by urmoms vibrator</center></i>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
!__EOF__
|
|
|
|
}
|
|
|
|
|
2015-12-04 16:26:39 +00:00
|
|
|
# usage: repodir and htmldir must be set.
|
2015-12-04 16:11:24 +00:00
|
|
|
if test x"$1" = x"" || test x"$2" = x""; then
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
|
2015-12-04 16:26:39 +00:00
|
|
|
# make absolute path to htmldir.
|
|
|
|
htmldir="$(readlink -f $2)"
|
|
|
|
mkdir -p "${htmldir}"
|
|
|
|
|
2015-12-04 16:11:24 +00:00
|
|
|
# repodir must be a directory to go to.
|
|
|
|
cd "$1" || usage
|
|
|
|
|
2015-12-04 16:26:39 +00:00
|
|
|
# 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')"
|
|
|
|
|
2015-12-04 16:11:24 +00:00
|
|
|
# TODO: make configurable.
|
|
|
|
baseurl="http://cow.codemadness.org/gitlog/"
|
|
|
|
|
2015-12-04 16:26:39 +00:00
|
|
|
indexpage="log.html"
|
|
|
|
|
2015-12-04 15:58:04 +00:00
|
|
|
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
|
2015-12-04 16:26:39 +00:00
|
|
|
test -e "${htmldir}/file/${file}.html" && continue
|
2015-12-04 15:58:04 +00:00
|
|
|
|
|
|
|
d=$(dirname "${file}")
|
2015-12-04 16:26:39 +00:00
|
|
|
mkdir -p "${htmldir}/file/${d}"
|
2015-12-04 15:58:04 +00:00
|
|
|
|
2015-12-04 16:26:39 +00:00
|
|
|
header > "${htmldir}/file/${file}.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
git show "${firstcommit}"...master "${file}" | \
|
2015-12-04 16:26:39 +00:00
|
|
|
sed -E 's@^commit (.*)$@commit <a href="commit/\1.html">\1</a>@g' >> "${htmldir}/file/${file}.html"
|
|
|
|
footer >> "${htmldir}/file/${file}.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# make log with all commits.
|
2015-12-04 16:26:39 +00:00
|
|
|
header > "${htmldir}/log.html"
|
|
|
|
printf '<table border="0">' >> "${htmldir}/log.html"
|
|
|
|
git log --pretty='<tr><td align="right">%cD</td><td><a href="commit/%H.html">%H</a></td><td>%an</td><td>%s</td></tr>' >> "${htmldir}/log.html"
|
|
|
|
printf '</table>' >> "${htmldir}/log.html"
|
|
|
|
footer >> "${htmldir}/log.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
|
|
|
|
# make diff for each commit (all files).
|
2015-12-04 16:26:39 +00:00
|
|
|
mkdir -p "${htmldir}/commit"
|
2015-12-04 15:58:04 +00:00
|
|
|
git log --pretty='%H' | while read -r commit; do
|
2015-12-04 16:26:39 +00:00
|
|
|
test -e "${htmldir}/commit/${commit}.html" && continue
|
|
|
|
header > "${htmldir}/commit/${commit}.html"
|
|
|
|
git show "${commit}" >> "${htmldir}/commit/${commit}.html"
|
|
|
|
footer >> "${htmldir}/commit/${commit}.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# make index with file links.
|
2015-12-04 16:26:39 +00:00
|
|
|
header >> "${htmldir}/files.html"
|
|
|
|
git ls-tree -r master | sed -E 's@ (.*)$@ <a href="file/\1.html">\1</a>@g' >> "${htmldir}/files.html"
|
|
|
|
footer >> "${htmldir}/files.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
|
|
|
|
# readme page
|
|
|
|
# find README file.
|
|
|
|
readme=""
|
|
|
|
for f in README README.md readme.md; do
|
|
|
|
test -e "${f}" && readme="${f}"
|
|
|
|
done
|
|
|
|
# make page.
|
2015-12-04 16:26:39 +00:00
|
|
|
header > "${htmldir}/readme.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
if test x"${readme}" != x""; then
|
2015-12-04 16:26:39 +00:00
|
|
|
cat "${readme}" >> "${htmldir}/readme.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
else
|
2015-12-04 16:26:39 +00:00
|
|
|
echo "no README file found" >> "${htmldir}/readme.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
fi
|
2015-12-04 16:26:39 +00:00
|
|
|
footer >> "${htmldir}/readme.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
|
|
|
|
# license page
|
|
|
|
# find LICENSE file.
|
|
|
|
license=""
|
|
|
|
for f in LICENSE LICENSE.md; do
|
|
|
|
test -e "${f}" && license="${f}"
|
|
|
|
done
|
|
|
|
# make page.
|
2015-12-04 16:26:39 +00:00
|
|
|
header > "${htmldir}/license.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
if test x"${readme}" != x""; then
|
2015-12-04 16:26:39 +00:00
|
|
|
cat "${license}" >> "${htmldir}/license.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
else
|
2015-12-04 16:26:39 +00:00
|
|
|
echo "unknown license" >> "${htmldir}/license.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
fi
|
2015-12-04 16:26:39 +00:00
|
|
|
footer >> "${htmldir}/license.html"
|
2015-12-04 15:58:04 +00:00
|
|
|
|
|
|
|
# stats (authors).
|
2015-12-04 16:26:39 +00:00
|
|
|
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"
|