blob: de4bb4a56e55da575f2e9541ebb3c5757f41d004 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
#!/bin/sh
# DEBUG
#set -e -x
usage() {
printf '%s <repodir> <htmldir>\n' "$0"
exit 1
}
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" />
<title>${description}</title>
<base href="${baseurl}" />
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<body>
<center>
<h1><img src="logo.png" alt="" /> ${description}</h1>
<a href="index.html">Tree</a> |
<a href="log.html">Log</a> |
<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__
}
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 <a href="commit/\1.html">\1</a>@g' >> "${logdir}/file/${file}.html"
footer >> "${logdir}/file/${file}.html"
done
# make log with all commits.
header > "${logdir}/log.html"
printf '<table border="0">' >> "${logdir}/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>' >> "${logdir}/log.html"
printf '</table>' >> "${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@ (.*)$@ <a href="file/\1.html">\1</a>@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"
|