Skip to content

Instantly share code, notes, and snippets.

@kiy0taka
Created September 9, 2010 02:46
Show Gist options
  • Save kiy0taka/571272 to your computer and use it in GitHub Desktop.
Save kiy0taka/571272 to your computer and use it in GitHub Desktop.
Using Groovy to SVN post-commit hook: IRC Bot to print commit Message
@Grab('pircbot:pircbot:1.4.2')
import org.jibble.pircbot.*;
def (host, port, channel) = ['<Server>', <Port>, '<Channel>']
def bot = [:] as PircBot
bot.name = 'groovy_bot'
bot.encoding = 'ISO-2022-JP'
bot.connect host, port
bot.joinChannel channel
bot.sendRawLine(args*.split('\n').flatten().collect{"PRIVMSG $channel :$it"}.join('\n'))
bot.disconnect()
System.exit 0
#!/bin/bash
export LANG=ja_JP.UTF-8
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk/
export GROOVY_HOME=/usr/local/groovy
export PATH=$JAVA_HOME/bin:$GROOVY_HOME/bin:$PATH
REPOS="$1"
REV="$2"
LOG=`svnlook log -r $REV $REPOS`
AUTHOR=`svnlook author -r $REV $REPOS`
CHANGES=`svnlook changed -r $REV $REPOS`
groovy /opt/svn/hoge/hooks/commit-irc.groovy "$AUTHOR" "$LOG" "$CHANGES" >> /tmp/post-commit.log 2>&1
@kiy0taka
Copy link
Author

kiy0taka commented Sep 9, 2010

For Git.

#!/bin/bash

export LANG=ja_JP.UTF-8
export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk/
export GROOVY_HOME=/usr/local/groovy
export PATH=$JAVA_HOME/bin:$GROOVY_HOME/bin:$PATH

LOG=`git log -1`

groovy /path/to/git-repo/hooks/commit-irc.groovy "$LOG" >> /tmp/post-commit.log 2>&1

@e2kaneko
Copy link

cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment