aboutsummaryrefslogtreecommitdiff
path: root/post-receive-stagit
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2022-11-20 23:31:40 +0100
committerSebastiano Tronto <sebastiano@tronto.net>2022-11-20 23:31:40 +0100
commit52b0be81663df26b56002533ec93f8008db04d1a (patch)
treead72ba13e6159d647b0bf2619c88c57924a19b82 /post-receive-stagit
downloadgit-hooks-52b0be81663df26b56002533ec93f8008db04d1a.tar.gz
git-hooks-52b0be81663df26b56002533ec93f8008db04d1a.zip
First commit
Diffstat (limited to 'post-receive-stagit')
-rwxr-xr-xpost-receive-stagit89
1 files changed, 89 insertions, 0 deletions
diff --git a/post-receive-stagit b/post-receive-stagit
new file mode 100755
index 0000000..396eefd
--- /dev/null
+++ b/post-receive-stagit
@@ -0,0 +1,89 @@
1#!/bin/sh
2
3repo="$PWD"
4name="$(basename $repo .git)"
5basedir="/var/www/htdocs/git.tronto.net"
6htdir="$basedir/$name"
7filesdir="/home/git/FILES"
8
9setupinfo() {
10 echo "Sebastiano Tronto" > owner
11 echo "https://git.tronto.net/$name" > url
12}
13
14genstagit() {
15 rm -rf "$htdir"
16 mkdir -p "$basedir"
17 cp -r "$repo" "$htdir"
18 cd "$htdir" && \
19 git update-server-info && \
20 git archive HEAD --prefix="$name/" -o "$basedir/$name.zip"
21 stagit -l 100 "$repo"
22 git show master:README.md > file/README.md
23}
24
25cpindexfile() {
26 cp "$htdir/files.html" "$htdir/index.html"
27}
28
29cpstylefiles() {
30 cp $filesdir/favicon.png "$1"
31 cp $filesdir/logo.png "$1"
32 cp $filesdir/style.css "$1"
33}
34
35formatreadme() {
36 printf '%s\n' \
37 g/class=\"line\"/d \
38 "/<pre id=\"blob\">" d d i "$(lowdown file/README.md)" . w \
39 | ed -s file/README.md.html > /dev/null
40}
41
42adddownloadbutton() {
43 printf '%s\n' \
44 "/log\.html\">Log<\/a>" i \
45 "<a href=\"../$name.zip\">Download</a> |" . w \
46 | ed -s "$1" > /dev/null
47}
48
49addbottombar() {
50 printf '%s\n' \
51 "/<\/body>" i "$(cat $filesdir/bottom.html)" . w \
52 | ed -s "$1" > /dev/null
53}
54
55changeindextitlestyle() {
56 printf '%s\n' \
57 "/<td><span class=\"desc\">Repositories" c \
58 "<td><h1>Repositories</h1></td></tr><tr><td></td><td>" . w \
59 | ed -s "$basedir/index.html" > /dev/null
60}
61
62genstagitindex() {
63 stagit-index /home/git/*.git | \
64 sed 's|/log\.html||g' > "$basedir/index.html"
65}
66
67mkpage() {
68 echo "Updating stagit page for $name"
69 setupinfo
70 genstagit
71 cpindexfile
72 cpstylefiles "./"
73 [ -e file/README.md ] && formatreadme
74 for f in $(find "$htdir" -name "*.html"); do
75 adddownloadbutton $f
76 addbottombar $f
77 done
78}
79
80mkindex() {
81 echo "Updating stagit index page"
82 genstagitindex
83 cpstylefiles "$basedir/"
84 addbottombar "$basedir/index.html"
85 changeindextitlestyle
86}
87
88mkpage
89mkindex

Generated with cgit - Back to sebastiano.tronto.net