Repo containing scripts to be used with dovel, and git hooks that powers our web interface.
Author: brian (brian@myr.sh)
Date: Wed Apr 17 13:38:44 2024 -0300
Parent: f0b6cfb
Removed raw folder - Using tmp folder for files
diff --git a/aux.sh b/aux.sh
index f1beaec..9e52a8e 100755
--- a/aux.sh
+++ b/aux.sh
@@ -55,7 +55,6 @@ pagesummary() {
<a href=/$1/refs.html>refs</a>  
<a href=/$1/log.html>log</a>  
<a href=/$1/tree.html>tree</a>  
- <a href=/$1/mail.html>mail</a>
</nav>
<p><i>$(cat description)</i></p>
</center>
diff --git a/post-receive b/post-receive
index f6a7183..c5bac7e 100755
--- a/post-receive
+++ b/post-receive
@@ -8,6 +8,7 @@
ROOT="$HOME/www/dovel.email"
REPO="$(basename $PWD)"
OUT="$ROOT/$REPO"
+TMP="$(mktemp -d)"
updategit() {
cat <<- EOF > "$ROOT/git.html"
@@ -60,7 +61,7 @@ updategit() {
updateindex() {
echo "creating archive"
- tar -C "$OUT" -cz raw/ --xform="s/raw/$REPO/" > "$OUT.tar.gz"
+ tar -C "$OUT" -cz $TMP/ --xform="s/$TMP/$REPO/" > "$OUT.tar.gz"
echo "creating index.html"
cat <<- EOF > "$OUT/index.html"
@@ -71,9 +72,9 @@ updateindex() {
<main>
EOF
- [ -f "$OUT/raw/README.md" ] && mdown < "$OUT/raw/README.md" >> "$OUT/index.html"
- [ -f "$OUT/raw/README" ] && cat <<- EOF >> "$OUT/index.html"
- <pre>$(cat "$OUT/raw/README")</pre>
+ [ -f "$TMP/README.md" ] && mdown < "$TMP/README.md" >> "$OUT/index.html"
+ [ -f "$TMP/README" ] && cat <<- EOF >> "$OUT/index.html"
+ <pre>$(cat "$TMP/README")</pre>
EOF
printf "\t</main>\n</body>\n</html>\n" >> "$OUT/index.html"
@@ -198,7 +199,7 @@ filepage() {
while IFS= read -r l
do
printf "<li>%s</li>\n" "$(printf "%s" "$l" | escapehtml)"
- done < "$OUT/raw/$1"
+ done < "$TMP/$1"
echo "</ol>\n</pre>\n</file>\n</body>\n</html>"
}
@@ -211,16 +212,15 @@ updatetree() {
<hr>
<h2>Tree</h2>
<table>
- <tr><th>Size</th><th>Name</th><th>Raw</th></tr>
+ <tr><th>Size</th><th>Name</th></tr>
EOF
- (cd "$OUT/raw" && find * -type f -printf '%s %p\n') | while read -r s f
+ (cd "$TMP" && find * -type f -printf '%s %p\n') | while read -r s f
do
cat <<- EOF >> "$OUT/tree.html"
<tr>
<td>$s</td>
<td><a href=tree/$f.html>$f</a></td>
- <td><a href=raw/$f>raw</a></td>
</tr>
EOF
@@ -243,21 +243,6 @@ updatetree() {
EOF
}
-initmail() {
- [ -f "$OUT/mail.html" ] && return
- echo "creating mail.html"
- cat <<- EOF > "$OUT/mail.html"
- $(pagehead "$REPO")
- $(pagesummary "$REPO")
- <hr>
- <h2>mail</h2>
- No mail here. To create a thread send an email to
- <a href="mailto:$REPO@dovel.email">$REPO@dovel.email</a>.
- </body>
- </html>
- EOF
-}
-
# first argument should be the version, e.g. v0.1.0
creategomod() {
# create page with meta tag
@@ -278,9 +263,8 @@ creategomod() {
rm -rf "$TMP"
}
-[ -d "$OUT/raw" ] && rm -rf "$OUT/raw"
[ -d "$OUT/log" ] || mkdir -p "$OUT/log"
-git clone . "$OUT/raw"
+git clone . "$TMP"
while read oldrev newrev ref
do
@@ -291,14 +275,13 @@ do
updaterefs
updatetree "$newrev"
updatelog
- initmail
;;
"refs/tags/v"*)
echo "received version tag $ref"
# check repo for go mod
tag="${ref#refs/tags/}"
- for mod in $(find "$OUT/raw/" -name go.mod)
+ for mod in $(find "$TMP/" -name go.mod)
do
creategomod "$tag"
done
@@ -306,3 +289,5 @@ do
*) echo "$ref received. Doing nothing." ;;
esac
done
+
+rm -rf "$TMP"