Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
Author: brian (git@myr.sh)
Date: Fri Sep 29 01:34:32 2023 -0300
Parent: f42ed74
Added script to fill logs
diff --git a/aux.sh b/aux.sh
index 8f35d47..842bdda 100755
--- a/aux.sh
+++ b/aux.sh
@@ -1,6 +1,6 @@
#!/bin/sh
-pageheader() {
+pagehead() {
cat <<- EOF
<!DOCTYPE html>
<html>
@@ -51,6 +51,24 @@ pageheader() {
EOF
}
+pagesummary() {
+ cat <<- EOF
+ ← <a href=/git.html>list</a>
+ <center>
+ <h1>$REPO</h1>
+ <nav>
+ <a href=/$REPO/index.html>index</a>  
+ <a href=/$REPO/refs.html>refs</a>  
+ <a href=/$REPO/log.html>log</a>  
+ <a href=/$REPO/tree.html>tree</a>  
+ <a href=/$REPO/mail.html>mail</a>
+ </nav>
+ <p><i>$(cat description)</i></p>
+ </center>
+ <kbd>curl https://dovel.email/$REPO/$REPO.zip</kbd>
+ EOF
+}
+
escapehtml() {
printf "%s" "$1" | sed -e 's/&/\&/g' -e 's/</\</g' -e 's/>/\>/g'
}
diff --git a/post-receive b/post-receive
index 7d85646..7b2db64 100755
--- a/post-receive
+++ b/post-receive
@@ -18,15 +18,5 @@ git clone . "$OUT/$REPO/tree"
# update repo's tree page
. ./hooks/update-repo-tree
-# create commit pages
-# while read oldrev newrev ref
-# do
-# # only checking out the master (or whatever branch you would like to deploy)
-# if [ "$ref" = "refs/heads/$BRANCH" ]
-# then
-# #git --work-tree="/home/blmayer/www/myr.sh" --git-dir="${GIT_DIR}" checkout -f ${BRANCH}
-# else
-# echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
-# fi
-# done
-
+# update repo's log page
+. ./hooks/update-repo-log
diff --git a/post-receive-scripts b/post-receive-scripts
index a0d0359..650c355 100755
--- a/post-receive-scripts
+++ b/post-receive-scripts
@@ -26,6 +26,7 @@ do
cp "$TMP/update-git-index" "$dir/hooks/"
cp "$TMP/update-repo-index" "$dir/hooks/"
cp "$TMP/update-repo-tree" "$dir/hooks/"
+ cp "$TMP/update-repo-log" "$dir/hooks/"
cp "$TMP/aux.sh" "$dir/hooks/"
done
@@ -40,6 +41,7 @@ done
. ./hooks/update-git-index
. ./hooks/update-repo-index
. ./hooks/update-repo-tree
+. ./hooks/update-repo-log
echo "cleaning up TMP"
rm -fr "$TMP"
diff --git a/update-git-index b/update-git-index
index 044f003..f2c7a06 100755
--- a/update-git-index
+++ b/update-git-index
@@ -6,7 +6,7 @@ echo "updating git pages"
# git.html lists all repos
cat << EOF > "$OUT/git.html"
- $(pageheader "dovel")
+ $(pagehead "dovel")
← <a href="/">dovel website</a>
<h1>Dovel project Git home</h1>
diff --git a/update-repo-log b/update-repo-log
new file mode 100755
index 0000000..b90b93e
--- /dev/null
+++ b/update-repo-log
@@ -0,0 +1,77 @@
+#!/bin/sh
+
+# for debugging
+# set -ex
+echo "updating git log"
+
+. ./hooks/aux.sh
+
+OUT="$HOME/www/dovel.email/$REPO"
+[ -d "$OUT/log" ] || mkdir -p "$OUT/log"
+
+createcommitpage() {
+ cat <<- EOF
+ $(pagehead "$REPO")
+ $(pagesummary)
+ <hr>
+ <h2>$1</h2>
+ EOF
+
+ # print commit
+ git show --format='%an%n%ae%n%ad%n%p%n%B' -s "$1" | {
+ read -r name
+ read -r email
+ read -r date
+ read -r parent
+
+ cat <<- EOF
+ <p>Author: $name ($email)</p>
+ <p>Date: $date</p>
+ <p>Parent: <a href=$parent>$parent</a></p>
+ <p><pre>
+ EOF
+
+ # the rest is the message
+ cat - <<- EOF
+ </pre>
+ <p>Diff</p>
+ <pre>
+ $(git diff "$1")
+ </pre>
+ </body>
+ </html>
+ EOF
+ }
+}
+
+echo "creating log.html"
+cat << EOF > "$OUT/log.html"
+ $(pageheader "$REPO")
+ $(pagesummary)
+ <hr>
+ <h2>Log</h2>
+ <table>
+ <tr><th>Hash</th><th>Author</th><th>Date</th></tr>
+EOF
+
+git log -n 100 --format='%h\n%ad\n%an\%s' | while read -r h
+do
+ read -r date
+ read -r name
+ read -r msg
+
+ [ -f "$OUT/log/$h.html" ] && break
+
+ echo "creating commit page $h"
+ cat <<- EOF >> "$OUT/log.html"
+ <tr><td><a href=$h.html>$h</a></td><td>$name</td><td>$date</td></tr>
+ <tr><td colspan=3>Subject: %msg</td></tr>
+ EOF
+ createcommitpage "$h" > "$OUT/log/$h.html"
+done
+cat << EOF
+</table>
+<p>Note: Only showing up to 100 commits, for full log clone the repo.</p>
+</body>
+</html>
+EOF
diff --git a/update-repo-tree b/update-repo-tree
index 229bb5a..cff98d6 100755
--- a/update-repo-tree
+++ b/update-repo-tree
@@ -9,20 +9,8 @@ echo "updating git tree"
OUT="$HOME/www/dovel.email/$REPO"
createfilepage() {
cat <<- EOF
- $(pageheader "$REPO")
- ← <a href=/git.html>list</a>
- <center>
- <h1>$REPO</h1>
- <nav>
- <a href=/$REPO/index.html>index</a>  
- <a href=/$REPO/refs.html>refs</a>  
- <a href=/$REPO/log.html>log</a>  
- <a href=/$REPO/tree.html>tree</a>  
- <a href=/$REPO/mail.html>mail</a>
- </nav>
- <p><i>$(cat description)</i></p>
- </center>
- <kbd>curl https://dovel.email/$REPO/$REPO.zip</kbd>
+ $(pagehead "$REPO")
+ $(pagesummary)
<hr>
<h2>$1</h2>
<file>
@@ -42,19 +30,7 @@ createfilepage() {
echo "creating tree.html"
cat << EOF > "$OUT/tree.html"
$(pageheader "$REPO")
- ← <a href=/git.html>list</a>
- <center>
- <h1>$REPO</h1>
- <nav>
- <a href=index.html>index</a>  
- <a href=refs.html>refs</a>  
- <a href=log.html>log</a>  
- <a>tree</a>  
- <a href=mail.html>mail</a>
- </nav>
- <p><i>$(cat description)</i></p>
- </center>
- <kbd>curl https://dovel.email/$REPO/$REPO.zip</kbd>
+ $(pagesummary)
<hr>
<h2>Tree</h2>
<table>
@@ -74,3 +50,8 @@ do
EOF
createfilepage "$f" > "$OUT/tree/$f.html"
done
+cat << EOF
+</table>
+</body>
+</html>
+EOF