From 9f965c1121b8e5e4028e16d84ea0fbb990b541f0 Mon Sep 17 00:00:00 2001 From: sakrecoer Date: Thu, 21 Nov 2024 17:25:13 +0100 Subject: [PATCH] add cron powered poor-man's git hook --- doktor-cron-poorman-githook.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 doktor-cron-poorman-githook.sh diff --git a/doktor-cron-poorman-githook.sh b/doktor-cron-poorman-githook.sh new file mode 100644 index 0000000..03d9597 --- /dev/null +++ b/doktor-cron-poorman-githook.sh @@ -0,0 +1,23 @@ +#!/bin/sh + +/usr/bin/git fetch + +UPSTREAM=${1:-'@{u}'} +LOCAL=$(/usr/bin/git rev-parse @) +REMOTE=$(/usr/bin/git rev-parse "$UPSTREAM") +BASE=$(/usr/bin/git merge-base @ "$UPSTREAM") + +if [ $LOCAL = $REMOTE ]; then + echo "Up-to-date" +elif [ $LOCAL = $BASE ]; then + echo "Need to pull" + + ######### + # AD YOUR MADNESS HERE! SKY IS THE LIMIT + ######### + +elif [ $REMOTE = $BASE ]; then + echo "Need to push" +else + echo "Diverged" +fi