Restructure
authorNeil Muller <drnlmuller@gmail.com>
Sun, 22 Mar 2020 12:39:07 +0000 (14:39 +0200)
committerNeil Muller <drnlmuller@gmail.com>
Sun, 22 Mar 2020 12:39:07 +0000 (14:39 +0200)
irker
post-receive
slack

diff --git a/irker b/irker
index eb4bd1e5960673ada30646c4f6482f09709b5672..436e190c0486b89ee03acb1fcb262b8dd1b31123 100755 (executable)
--- a/irker
+++ b/irker
@@ -2,7 +2,7 @@
 
 IRKERPATH=/usr/bin/
 
-function help() {
+function help_irker() {
   echo "Required config settings:"
   echo "  git config irker.channels 'channel1 channel2 ..'"
   echo "  git config irker.project 'Project name'"
@@ -16,6 +16,9 @@ function notify_irker() {
    new=$2
    refname=$3
 
+   echo "irker $1 $2 $3"
+   return 
+
    if [ "x$old" = "x0000000000000000000000000000000000000000" ]; then
       # We're pushing into an empty repo, so we need a different command
       # to get the rev list
@@ -36,15 +39,3 @@ function notify_irker() {
            $(git rev-list --reverse ${old}..${new})
    fi
 }
-
-channels=$(git config --get irker.channels)
-
-while read line; do
-  set -- $line
-  if [ -n "$channels" ]; then
-      notify_irker $*
-  fi
-  RET=$?
-done
-
-exit $RET
index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..3aeae3572f0315bbad6453a8416b2f0705d74134 100755 (executable)
@@ -0,0 +1,23 @@
+#!/bin/bash
+HOOKDIR=$(dirname $0)
+
+# Load functions
+. $HOOKDIR/irker
+. $HOOKDIR/slack
+
+
+channels=$(git config --get irker.channels)
+
+webhook_url=$(git config --get hooks.slack.webhook-url)
+
+while read line; do
+    set -- $line
+    if [ -n "$channels" ]; then
+        notify_irker $*
+     fi
+     if [ -n "$webhook_url" ]; then
+        notify_slack $*
+     fi
+     RET=$?
+done
+exit $RET
diff --git a/slack b/slack
index 45187cfe5b92ecd069760d374cc161d4f227fadb..ac6e1143f7cc8e5a79fe9d74235c7860dedcbc6f 100755 (executable)
--- a/slack
+++ b/slack
@@ -8,7 +8,7 @@
 # Based on post-receive.irc by Mikael Fridh <frimik@gmail.com> https://gist.github.com/1821358
 #
 
-function help() {
+function help_slack() {
   echo "Required config settings:"
   echo " git config hooks.slack.webhook-url 'https://hooks.slack.com/services/...'"
   echo " git config hooks.slack.channel 'general'"
@@ -22,6 +22,9 @@ function notify_slack() {
   newrev=$(git rev-parse $2)
   refname="$3"
 
+   echo "slack $1 $2 $3"
+   return
+
   # --- Interpret
   # 0000->1234 (create)
   # 1234->2345 (update)
@@ -233,16 +236,3 @@ function notify_slack() {
       "$webhook_url" \
       >/dev/null
 }
-
-webhook_url=$(git config --get hooks.slack.webhook-url)
-
-while read line; do
-  set -- $line
-  if [ -n "$webhook_url" ]; then
-      notify_slack $*
-  fi
-
-  RET=$?
-done
-
-exit $RET