Skip to content

Instantly share code, notes, and snippets.

@Ram-Z
Created February 4, 2015 16:13
Show Gist options
  • Save Ram-Z/f14da1d965a35df065f1 to your computer and use it in GitHub Desktop.
Save Ram-Z/f14da1d965a35df065f1 to your computer and use it in GitHub Desktop.
#!/bin/bash
# configuration
path=/tmp/aide
server='irc.freenode.net'
channel='#chakra-devel'
# file to append messages to
out="$path/$server/$channel/in"
# read input, extract branch&repo names
read oldrev newrev ref
branch=${ref/refs\/heads\//}
repo=$(basename $(pwd)|sed 's/\.git$//') # feel free to hardcode it
url="http://git.chakraos.org/${repo}/"
# commits to consider
if [ "$oldrev" == '0000000000000000000000000000000000000000' ]
then
# new branch!
echo "New branch: $repo/$branch" >> $out
# get all revisions specific to this branch
commits="$(git for-each-ref --format='%(refname)' 'refs/heads/*' \ |grep -v "$ref"|sed 's/^/\^/') $newrev"
else
# range of revisions
commits="$oldrev..$newrev"
fi
# count number of commits
num=$(git rev-list $commits --count)
s=$([ "$num" != '1' ] && echo 's') # plural
# generate messages
echo "%a pushed $num commit$s to $repo/$branch - $url/shortlog/${oldrev}..$newrev"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment