Fix syntax errors
[gitolite-hooks.git] / slack
diff --git a/slack b/slack
old mode 100644 (file)
new mode 100755 (executable)
index e83153c..a8055eb
--- a/slack
+++ b/slack
@@ -8,20 +8,13 @@
 # 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'"
   echo " git config hooks.slack.show-only-last-commit 'true' #optional"
   echo " git config hooks.slack.username 'git' #optional"
-  echo " git config hooks.slack.icon-url 'http://imgur/icon.png' #optional"
-  echo " git config hooks.slack.icon-emoji ':twisted_rightwards_arrows:' #optional"
   echo " git config hooks.slack.repo-nice-name 'MyRepo' #optional"
-  echo " git config hooks.slack.repos-root '/path/to/repos' #optional"
-  echo " git config hooks.slack.changeset-url-pattern 'http://yourserver/%repo_path%/changeset/%rev_hash
-%' #optional"
-  echo " git config hooks.slack.compare-url-pattern 'http://yourserver/%repo_path%/changeset/%old_rev_ha
-sh%..%new_rev_hash%' #optional"
 }
 
 function notify_slack() {
@@ -164,30 +157,9 @@ function notify_slack() {
 
 
   if [[ "${change_type}" != "delete" && "${refname_type}" == "branch" ]]; then
-    changeseturlpattern=`git config --get hooks.slack.changeset-url-pattern`
-    compareurlpattern=`git config --get hooks.slack.compare-url-pattern`
     reporoot=`git config --get hooks.slack.repos-root`
 
     urlformat=
-    if [ -n "$changeseturlpattern" -a -n "$reporoot" ]; then
-      if [[ $PWD == ${reporoot}* ]]; then
-        repopath=$PWD
-        base=`basename $PWD`
-        if [ "$base" == ".git" ]; then
-          repopath=`dirname $repopath`
-        fi
-        idx=`echo $reporoot | wc -c | tr -d ' '`
-        repopath=`echo $repopath | cut -c$idx-`
-        urlformat=`echo $changeseturlpattern | sed "s|%repo_path%|$repopath|g" | sed "s/%rev_hash%/%H/g"`
-
-        if [ -n "$compareurlpattern" ]; then
-          comparelink=`echo $compareurlpattern | sed "s|%repo_path%|$repopath|g"  | sed "s|%old_rev_hash%|$oldrev|g" | sed "s|%new_rev_hash%|$newrev|g"`
-          header=`echo $header | sed -e "s|\([a-zA-Z0-9]\{1,\} new commit[s]\{0,1\}\)|\<$comparelink\|\\1\>|"`
-        fi
-      else
-        echo >&2 "$PWD is not in $reporoot. Not creating hyperlinks."
-      fi
-    fi
 
     formattedurl=""
     if [ -n "$urlformat" ]; then
@@ -235,8 +207,6 @@ function notify_slack() {
   webhook_url=$(git config --get hooks.slack.webhook-url)
   channel=$(git config --get hooks.slack.channel)
   username=$(git config --get hooks.slack.username)
-  iconurl=$(git config --get hooks.slack.icon-url)
-  iconemoji=$(git config --get hooks.slack.icon-emoji)
 
   if [ -z "$webhook_url" ] || [ -z "$channel" ]; then
     echo "ERROR: config settings not found"
@@ -250,12 +220,6 @@ function notify_slack() {
     payload="$payload, \"username\": \"$username\""
   fi
 
-  if [ -n "$iconurl" ]; then
-    payload="$payload, \"icon_url\": \"$iconurl\""
-  elif [ -n "$iconemoji" ]; then
-    payload="$payload, \"icon_emoji\": \"$iconemoji\""
-  fi
-
   payload="$payload}"
 
   if [ -n "$DEBUG" ]; then
@@ -269,16 +233,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