diff --git a/CVSROOT/ciabotsh b/CVSROOT/ciabotsh index 348e3e51..279872f7 100755 --- a/CVSROOT/ciabotsh +++ b/CVSROOT/ciabotsh @@ -1,102 +1,51 @@ #!/bin/bash - -# This script should be called as "ciabot %{}" from loginfo. -# Sample loginfo line: -# ALL $CVSROOT/CVSROOT/ciabot %{sVv} -# Put that in your CVSROOT/loginfo, then set the variables at the top of this -# script. Then commit this file to your CVSROOT, and add it to -# CVSROOT/checkoutlist, and -# echo | mail -s "JoinChannel #myproject" commits@picogui.org - -projectname="zsnes" # will announce to channel # -returnaddress="pagefault@zsnes.com" - -# You should turn stripnewlines on if you tend to write short blocks -# of text, and off if you tend to have any formatting. If you stick -# full changelog entries in your commit messages, definitely turn it -# off. -stripnewlines=false -#stripnewlines=true - -# If your logs don't include the name of the modified file, and you want to -# show it, turn this on -includefilename=false -#includefilename=true - -# Deliver directly to the bot: -commitaddress="commits@picogui.org" -# Sourceforge projects might need to deliver via users.sf.net (slower) -#commitaddress="cia@users.sf.net" - -#################### End of what you'll generally need to change - -echo -n "Notifying #${projectname}..." - -maxlines=6 +module=`echo $1 | cut -d/ -f1` message=`cat` uname=`id -un` lineno=`echo "$message" | grep -n "Log Message:" | awk -F: ' { print $1 } '` message=`echo "$message" | sed "1,${lineno}d"` -newline=`echo` -if [ "$message" != "`echo \"$message\" | head -n $maxlines`" ]; then -# The following line appears to be the only way to insert a newline at -# that place. - message="`echo \"$message\" | head -n $(($maxlines - 1))` -<...>" -fi - -if $stripnewlines; then - message=`echo -n "$message" | tr '\n\r' ' '` -fi - -module=`echo $1 | cut -d/ -f1` - -## disabled, as it might cause repeated messages -#if $includefilename; then -# directory=`echo $1 | cut -d" " -f1` -# filename=`echo $1 | cut -d" " -f2 | cut -d"," -f1` -# module="$directory/$filename" -#fi - -# the /tmp directory often has its sticky bit set, so do things -# in a private subdir so we can have shared state -tmpdir="/tmp/ciabot.cvs" -if [ ! -d $tmpdir ]; then - mkdir $tmpdir; - chmod 0777 $tmpdir -fi -tmpfile="$tmpdir/$RANDOM-$projectname" +projectname="zsnes" +tmpfile="/tmp/$RANDOM-$projectname" +tmpfilea="/tmp/$RANDOM--$projectname" +message=`echo "$message" | head -n 5` +#message=`echo $message | tr '\n\r' ' '` cat <$tmpfile -From: $returnaddress -To: $commitaddress +From: pagefault@users.sourceforge.net +To: commits@picogui.org Content-Type: text/plain; Subject: Announce $projectname -commit by $uname to $module: $message +commit to module {green}$module{normal} by {orange}$uname{normal}: $message EOF -lastlog="$tmpdir/lastlog-$projectname" -if [ -r $lastlog ]; then - if ! diff $lastlog $tmpfile &>/dev/null; then - # there are differences, so this is a different commit - cat $tmpfile | /usr/sbin/sendmail -t - # try to replace the lastlog if we're allowed - if [ -w $lastlog ]; then - mv $tmpfile $lastlog - # allow the next person to overwrite - chmod a+w $lastlog + +if [ -e /tmp/lastlog-$projectname ]; then + if ! diff /tmp/lastlog-$projectname $tmpfile &>/dev/null; then + # there are differences, so this is a different commit + cat $tmpfile | /usr/sbin/sendmail -t + mv $tmpfile /tmp/lastlog-$projectname + else + # it's just cvs spamming us from another directory + rm $tmpfile fi - else - # it's just cvs spamming us from another directory - rm $tmpfile - fi else - cat $tmpfile | /usr/sbin/sendmail -t - mv $tmpfile $lastlog - # To ensure that the next person to commit will be able to overwrite - chmod a+w $lastlog + cat $tmpfile | /usr/sbin/sendmail -t + mv $tmpfile /tmp/lastlog-$projectname +fi + +if [ -e /tmp/lastlog-$projectname ]; then + if ! diff /tmp/lastloga-$projectname $tmpfilea &>/dev/null; then + # there are differences, so this is a different commit + cat $tmpfilea | /usr/sbin/sendmail -t + mv $tmpfilea /tmp/lastloga-$projectname + else + # it's just cvs spamming us from another directory + rm $tmpfilea + fi +else + cat $tmpfilea | /usr/sbin/sendmail -t + mv $tmpfilea /tmp/lastloga-$projectname fi -echo "done."