Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
Author: blmayer (bleemayer@gmail.com)
Date: Tue Oct 3 00:40:05 2023 -0300
Parent: 552cf3b
Fixed diff files
#!/bin/sh # for debugging # set -ex . hooks/aux.sh # . ./aux.sh ROOT="$HOME/www/dovel.email" REPO="$(basename $PWD)" OUT="$ROOT/$REPO" updategit() { cat <<- EOF > "$ROOT/git.html" $(pagehead "dovel") ← <a href="/">dovel website</a> <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 "$HOME/git/dovel.email/"* do cat <<- EOF >> "$ROOT/git.html" <dt><a href=$(basename $dir)/index.html>$(basename $dir)</a></dt> <dd>$(cat "$dir/description")</dd> EOF done cat <<- EOF >> "$ROOT/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 } updateindex() { echo "creating archives" tar -C "$OUT" -cz tree/ --xform="s/tree/$REPO/" > "$OUT.tar.gz" echo "creating index.html" cat <<- EOF > "$OUT/index.html" $(pagehead "$REPO") $(pagesummary "$REPO") <hr> <p>Latest commit: $(git log -n 1 --format="(%h) by %an at %as: %s")</p> <pre>$(cat "$OUT/tree/README"*)</pre> </body> </html> EOF } filepage() { cat <<- EOF $(pagehead "$REPO") $(pagesummary "$REPO") <hr> <h2>$1</h2> <file> <pre> <ol> EOF # print file while IFS= read -r l do printf "<li>%s</li>\n" "$(escapehtml "$l")" done < "$OUT/tree/$1" echo "</ol>\n</pre>\n</file>\n</body>\n</html>" } createcommitpage() { cat <<- EOF $(pagehead "$REPO") $(pagesummary "$REPO") <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.html>$parent</a></p> <p><pre> EOF # the rest is the message cat - } # now the diff cat <<- EOF </pre> <h3>Diff</h3> EOF for f in $(git show "$1" --name-only --format='') do cat <<- EOF <h4>$f</h4> <pre style="overflow-x:auto;white-space:pre"> EOF git show --format='' "$1:$f" | while read -r l do printf "%s\n" "$(escapehtml "$l")" done echo "</pre>" done cat <<- EOF </body> </html> EOF } updatelog() { echo "creating log.html" cat <<- EOF > "$OUT/log.html" $(pagehead "$REPO") $(pagesummary "$REPO") <hr> <h2>Log</h2> <table> <tr><th>Hash</th><th>Author</th><th>Date</th><th>Subject</td></tr> EOF git log -n 100 --format='%h%n%ad%n%an%n%s' --date=iso | while read -r h do read -r date read -r name read -r msg cat <<- EOF >> "$OUT/log.html" <tr><td><a href=log/$h.html>$h</a></td><td>$name</td><td>$date</td><td>$msg</td></tr> EOF [ -f "$OUT/log/$h.html" ] && continue echo "creating commit page $h" createcommitpage "$h" > "$OUT/log/$h.html" done cat <<- EOF >> "$OUT/log.html" </table> <p>Note: Only showing up to 100 commits, for full log clone the repo.</p> </body> </html> EOF } updaterefs() { echo "creating refs.html" cat <<- EOF > "$OUT/refs.html" $(pagehead "$REPO") $(pagesummary "$REPO") <hr> <h2>Branches</h2> <table> EOF git show-ref --heads | while read -r h n do echo "<tr><td>$h</td><td>$n</td></tr>" >> "$OUT/refs.html" done echo "</table>\n<h2>Tags</h2>\n<table>" >> "$OUT/refs.html" git show-ref --tags | while read -r h n do echo "<tr><td>$h</td><td>$n</td></tr>" >> "$OUT/refs.html" done cat <<- EOF >> "$OUT/refs.html" </table> </body> </html> EOF } updatetree() { echo "creating tree.html" cat <<- EOF > "$OUT/tree.html" $(pagehead "$REPO") $(pagesummary "$REPO") <hr> <h2>Tree</h2> <table> <tr><th>Size</th><th>Name</th><th>Raw</th></tr> EOF (cd "$OUT/tree" && find * -type f -printf '%s %p\n') | while read -r s f do echo "updating file $f" cat <<- EOF >> "$OUT/tree.html" <tr> <td>$s</td> <td><a href=tree/$f.html>$f</a></td> <td><a href=tree/$f>raw</a></td> </tr> EOF filepage "$f" > "$OUT/tree/$f.html" done cat <<- EOF >> "$OUT/tree.html" </table> </body> </html> EOF } # first argument should be the version, e.g. v0.1.0 creategomod() { [ -d "$OUT/@latest" ] || mkdir -p "$OUT/@latest" [ -d "$OUT/@v/$1" ] || mkdir -p "$OUT/@v/$1" find "$OUT/tree/"* -print | sed "s:$OUT/tree/:dovel.email/$REPO@v$1/" | zip -@ > "$OUT/@v/$1.zip" cp "$OUT/$1.zip" "$OUT/@latest/" } [ -d "$OUT/tree" ] && rm -rf "$OUT/tree" [ -d "$OUT/log" ] || mkdir -p "$OUT/log" git clone . "$OUT/tree" while read oldrev newrev ref do case "$ref" in "refs/heads/main") updategit updateindex updaterefs updatetree updatelog ;; "refs/tags/v"*) echo "received version tag $ref" # check repo for go mod tag="${ref#refs/tags/}" find "$OUT/tree/" -name go.mod && creategomod "$tag" ;; *) echo "$ref received. Doing nothing." ;; esac done