Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
Author: brian (git@myr.sh)
Date: Tue Sep 19 20:43:55 2023 -0300
Parent: 6993e2a
Separated scripts
diff --git a/post-receive b/post-receive
index 4935cd5..599c628 100755
--- a/post-receive
+++ b/post-receive
@@ -2,100 +2,29 @@
# for debugging
# set -ex
-echo "updating git pages"
OUT="$HOME/www/dovel.email"
GITDIR="$HOME/git/dovel.email"
-# git.html lists all repos
-cat << EOF > "$OUT/git.html"
-<!DOCTYPE html>
-<html>
-<head>
- <title>dovel's git</title>
- <meta charset="UTF-8">
- <meta name="author" content="Brian Lee Mayer">
- <meta name="description" content="This is the development homepage of the Dovel project. Find here all repos mailing lists. And latest development changes.">
- <meta name="language" content="english">
- <meta name="keywords" content="email, dovel, blmayer, self host, software, smtp, web, interface">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="color-scheme" content="light dark">
- <style>
- body {
- max-width: 600px;
- margin: 60px auto;
- padding: 20px;
- font-family: sans-serif;
- }
- pre {
- font-weight: bold;
- background: lightgray;
- padding: 8px;
- border-radius: 8px;
- }
- ol li {padding-bottom: 10px}
- tt {font-weight: bold}
- @media (prefers-color-scheme: dark) {
- pre {background: darkslategray}
- }
- </style>
-</head>
-<body>
- <h1>Dovel project Git home</h1>
- Welcome! Here you'll find general info about our projects and how to
- contribute to them. We proudly use dovel email technology for our
- mailing lists. Its hooks are in the scripts repo. Please read the next
- sections before making a contribution.
- <h2>Repositories</h2>
- <dl>
-EOF
+# latter on the latest commits section
+# git --git-dir "$dir" log -n 1 --format="%h at %ah"
-for dir in "$GITDIR"/*
-do
- {
- cat <<- EOF
- <dt><a href=$(basename $dir)/index.html>$(basename $dir)</a></dt>
- <dd>$(cat "$dir/description")</dd>
- <dd>Last commit
- EOF
- git --git-dir "$dir" log -n 1 --format="%h at %dh"
- echo "</dd>"
- } >> "$OUT/git.html"
-done
-
-cat << EOF >> "$OUT/git.html"
- </dl>
-
- <h2>Contributing</h2>
- The dovel team uses the git email workflow to accept contributions.
- All email sent to dovel.email is considered as git mailling lists, check
- each repository for email to a specific project. To send email about
- other subjects please address them to
- <a href=mailto:dovel@myr.sh>dovel@myr.sh</a>.
+# update git's index page
+sh ./hooks/update-git-index
- <h3>Email addresses</h3>
- To send contributions use the repo name as the email's recipient, i.e.
- to contribute to the server project send email to
- <kbd>server@dovel.email</kbd>.
+# update repo's index page
+sh ./hooks/update-repo-index
- <h3>Email etiquette</h3>
- We only accept plain text email. More info and recomendations can be
- found on <a href=//useplaintext.email>useplaintext.email</a>.
-</body>
-</html>
-EOF
-
-# repo specific
# 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
+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
diff --git a/post-receive-scripts b/post-receive-scripts
index 8af544d..f836ff2 100755
--- a/post-receive-scripts
+++ b/post-receive-scripts
@@ -3,10 +3,6 @@
#for debugging
#set -ex
-
-# the location of the .git directory
-# GIT_DIR="/home/blmayer/git/dovel/scripts"
-
BRANCH="main"
while read oldrev newrev ref
@@ -14,19 +10,28 @@ do
# only checking out the master (or whatever branch you would like to deploy)
if [ "$ref" = "refs/heads/$BRANCH" ]
then
- echo "Ref $ref received. Deploying ${BRANCH} branch on server..."
+ echo "Ref $ref received. Updating git pages"
TMP="$(mktemp -d)"
git --work-tree="$TMP" checkout -f ${BRANCH}
- cp "$TMP/post-receive-scripts" "./hooks/post-receive"
- cp "$TMP/post-receive" "./hooks/update-html"
- cp "$TMP/post-receive" "../web/hooks/post-receive"
- cp "$TMP/post-receive" "../server/hooks/post-receive"
+
+ # copy main scripts to projects
+ for dir in ../*
+ do
+ cp "$TMP/post-receive" "$dir/hooks/"
+ cp "$TMP/update-git-index" "$dir/hooks/"
+ cp "$TMP/update-repo-index" "$dir/hooks/"
+ done
+
+ # for this repo copy scripts
+ rm ./hooks/post-receive
+ cp "$TMP/post-receive-scripts" ./hooks/post-receive
else
- echo "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
+ echo "Ref $ref received. Doing nothing."
fi
done
-sh ./hooks/update-html
+sh ./hooks/update-git-index
+sh ./hooks/update-repo-index
echo "cleaning up TMP"
rm -fr "$TMP"
diff --git a/update-git-index b/update-git-index
new file mode 100755
index 0000000..1d66e8d
--- /dev/null
+++ b/update-git-index
@@ -0,0 +1,83 @@
+#!/bin/sh
+
+echo "updating git pages"
+OUT="$HOME/www/dovel.email"
+GITDIR="$HOME/git/dovel.email"
+
+# git.html lists all repos
+cat << EOF > "$OUT/git.html"
+<!DOCTYPE html>
+<html>
+<head>
+ <title>dovel's git</title>
+ <meta charset="UTF-8">
+ <meta name="author" content="Brian Lee Mayer">
+ <meta name="description" content="This is the development homepage of the Dovel project. Find here all repos mailing lists. And latest development changes.">
+ <meta name="language" content="english">
+ <meta name="keywords" content="email, dovel, blmayer, self host, software, smtp, web, interface">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="color-scheme" content="light dark">
+ <style>
+ body {
+ max-width: 600px;
+ margin: 60px auto;
+ padding: 20px;
+ font-family: sans-serif;
+ }
+ pre {
+ font-weight: bold;
+ background: lightgray;
+ padding: 8px;
+ border-radius: 8px;
+ }
+ ol li {padding-bottom: 10px}
+ tt {font-weight: bold}
+ @media (prefers-color-scheme: dark) {
+ pre {background: darkslategray}
+ }
+ </style>
+</head>
+<body>
+ <h1>Dovel project Git home</h1>
+ Welcome! Here you'll find general info about our projects and how to
+ contribute to them. We proudly use dovel email technology for our
+ mailing lists. Its hooks are in the scripts repo. Please read the next
+ sections before making a contribution.
+
+ <h2>Repositories</h2>
+ <dl>
+EOF
+
+for dir in "$GITDIR"/*
+do
+ cat <<- EOF >> "$OUT/git.html"
+ <dt><a href=$(basename $dir)/index.html>$(basename $dir)</a></dt>
+ <dd>$(cat "$dir/description")</dd>
+ EOF
+done
+
+cat << EOF >> "$OUT/git.html"
+ </dl>
+
+ <h2>Contributing</h2>
+ The dovel team uses the git email workflow to accept contributions.
+ All email sent to dovel.email is considered as git mailling lists, check
+ each repository for email to a specific project. To send email about
+ other subjects please address them to
+ <a href=mailto:dovel@myr.sh>dovel@myr.sh</a>.
+
+ <h3>Email addresses</h3>
+ To send contributions use the repo name as the email's recipient, i.e.
+ to contribute to the server project send email to
+ <kbd>server@dovel.email</kbd>. Please CC me as well so I can reply
+ faster: <kbd>dovel@myr.sh</kbd>.
+
+ <h3>Email etiquette</h3>
+ We only accept plain text email. More info and recomendations can be
+ found on <a href=//useplaintext.email>useplaintext.email</a>. Also
+ <a href=//git-send-email.io>git-send-email.io</a> has instructions on
+ how to setup git to send email for many platforms.
+</body>
+</html>
+EOF
+
diff --git a/update-repo-index b/update-repo-index
new file mode 100755
index 0000000..329f388
--- /dev/null
+++ b/update-repo-index
@@ -0,0 +1,74 @@
+#!/bin/sh
+
+# for debugging
+# set -ex
+echo "updating git index"
+
+REPO="$(basename $PWD)"
+OUT="$HOME/www/dovel.email/$REPO"
+
+[ -d "$OUT" ] || mkdir "$OUT"
+
+# archives
+echo "creating archives"
+TMP="$(mktemp -d)"
+git clone . "$TMP"
+tar -czf "$OUT/$REPO.zip" "$TMP"
+git archive -o "$OUT/$REPO-HEAD.zip" HEAD
+
+echo "creating index.html"
+cat << EOF > "$OUT/index.html"
+<!DOCTYPE html>
+<html>
+<head>
+ <title>$REPO's git</title>
+ <meta charset="UTF-8">
+ <meta name="author" content="Brian Lee Mayer">
+ <meta name="description" content="This is the development homepage of the Dovel project, this is the repo $REPO. Find here code, all mailing lists and latest development changes.">
+ <meta name="language" content="english">
+ <meta name="keywords" content="email, dovel, blmayer, self host, software, smtp, web, interface">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="color-scheme" content="light dark">
+ <style>
+ body {
+ max-width: 600px;
+ margin: 60px auto;
+ padding: 20px;
+ font-family: sans-serif;
+ }
+ pre {
+ font-weight: bold;
+ background: lightgray;
+ padding: 8px;
+ border-radius: 8px;
+ }
+ ol li {padding-bottom: 10px}
+ tt {font-weight: bold}
+ @media (prefers-color-scheme: dark) {
+ pre {background: darkslategray}
+ }
+ </style>
+</head>
+<body>
+ <center>
+ <h1>$REPO</h1>
+ <i>$(cat description)</i>
+ <nav>
+ <a>index</a>  
+ <a href=refs.html>refs</a>  
+ <a href=log.html>log</a>  
+ <a href=tree.html>tree</a>  
+ <a href=mail.html>mail</a>
+ </nav>
+ </center>
+ zip: <kbd>curl dovel.email/$REPO/$REPO.zip</kbd>
+ <p>
+ Latest commit:
+ $(git --git-dir "$dir" log -n 1 --format="%an commited (%h) at %ah: %s")
+ </p>
+ <hr>
+ <pre>$(cat "$TMP/README" "$TMP/README.md")</pre>
+</body>
+</html>
+EOF
+