commit 2338201c5403dfff09dde7bef7bf0175f5174cca
parent 86984a203f23f98a951025cf9fe9b1617f495012
Author: Eamon Caddigan <eamon.caddigan@gmail.com>
Date: Sun, 8 Dec 2024 00:02:26 -0800
Add addendum to day 4 December Adventure log
Diffstat:
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/content/december-adventure/2024-04/index.md b/content/december-adventure/2024-04/index.md
@@ -1,17 +1,17 @@
---
title: "2024, Day 4: Git pre-push hook for Hugo, part 2"
date: 2024-12-04T14:48:25-08:00
-description: "Prevent pushing drafts to origin"
+description: "Prevent pushing drafts to production"
draft: false
---
Well this is kludgey and frail, but I've worked out a pre-push hook that
should stop me from pushing (most) drafts to my website (which is published
-when I push my repository to origin/main, hence the check on line 12).
+when I push my repository to prod/main, hence the check on line 12).
```bash
#!/bin/sh
-# Prevent a push to origin/main if a suspected draft post is found
+# Prevent a push to prod/main if a suspected draft post is found
remote="$1"
url="$2"
@@ -21,7 +21,7 @@ z40=0000000000000000000000000000000000000000
while read local_ref local_sha remote_ref remote_sha
do
- if [ "$remote $remote_ref" = "origin refs/heads/main" ]
+ if [ "$remote $remote_ref" = "prod refs/heads/main" ]
then
if [ "$remote_sha" = $z40 ]
then
@@ -55,3 +55,9 @@ like multiline parameters. TBH I probably wouldn't even share something like
this if I wasn't working on #DecemberAdventure. But I suspect that I'll
refine it if and when I'm annoyed by any misses (false positives and
negatives alike), so maybe it'll become decent someday.
+
+## Update: Day 7
+
+I edited the hook to check for the `prod` remote instead of `origin`. My
+`origin` repository still points to the version at
+<https://git.eamoncaddigan.net/www.eamoncaddigan.net>.