Skip to content

Instantly share code, notes, and snippets.

@orangle
Created November 7, 2016 09:31
Show Gist options
  • Save orangle/551db789d71b2b7a5d9e3b2d817d6d94 to your computer and use it in GitHub Desktop.
Save orangle/551db789d71b2b7a5d9e3b2d817d6d94 to your computer and use it in GitHub Desktop.
BearyChat SVN hook,svn commit 自动提交叫bc的web hooks
#!/bin/bash
export LANG='zh_CN.UTF-8'
# bearychat svn
# Requires Curl and Subversion Server installed.
# Put this file as "post-commit" with 755 permissions on the hooks directory of your repo
REPO_PATH=$1
REV=$2
LOOK=/usr/bin/svnlook
CURL=/usr/bin/curl
AWK=/usr/bin/awk
# write your web hook url
URL="https://hook.bearychat.com/=bw9uO/incoming/4xxxxxxxxxxxxxxxxx"
RES=`${LOOK} info -r $REV $REPO_PATH`
COMMIT=`echo "$RES" | ${AWK} 'BEGIN{RS="\n\n"; FS="\n"} {print $4}'`
USER=`echo "$RES" | ${AWK} 'BEGIN{RS="\n\n"; FS="\n"} {print $1}'`
MSG="$REV by $USER: $COMMIT"
JSON="{
\"text\": \"Subversion\",
\"attachments\": [
{
\"title\": \"Revision\",
\"text\": \"$REV\",
\"color\": \"#ffa500\"
},
{
\"title\": \"User\",
\"text\": \"$USER\",
\"color\": \"#ffa500\"
},
{
\"title\": \"Changes\",
\"text\": \"$COMMIT\",
\"color\": \"#ffa500\"
}
]
}"
echo $JSON > /tmp/svn.log
$CURL -X POST --data "payload=$JSON" $URL
@orangle
Copy link
Author

orangle commented Nov 7, 2016

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