Piotr Kucharski 2003-02-15 CVS: How to make it send you diffs of committed work? ===================================================== 'CVSROOT/loginfo' file is used to control where "cvs commit" log information is sent. (Read more about it inside the file itself) As we work on ircd project, we commit to irc tree. Hence such an entry: ^irc.* $CVSROOT/CVSROOT/dolog %{sVv} 'dolog' script is a kind of a go-between -- as I wanted mails to be sent not every commit, but every hour, with possibly accumulated content. Script itself is very simple: #!/bin/sh cd /home/chopin/.cvs umask 002; echo $* >> commits.prep (echo ""; echo $USER; date; cat) >> commits What it does, is a) recording changed filenames (%s) along with their previous (%V) and current (%v) versions in 'commits.prep' file; it might look like this: irc/doc ChangeLog,1.187,1.188 2.11-New,1.8,1.9 irc/ircd s_bsd.c,1.94,1.95 b) recording log message (yes, it is piped to stdin) to 'commits' file; it might look like (series of) this: chopin Sat Feb 15 21:02:32 EST 2003 Update of /usr/local/repository/irc/doc In directory oink:/tmp/cvs-serv23473 Modified Files: 2.11-New Log Message: minor doc change Now, I have a cron job, executing 'rotate' script every hour. This one does the magic of diffing, here: #!/bin/sh PATH=/usr/bin:/usr/local/bin WDIR=/home/chopin/.cvs cd $WDIR if [ ! -f commits.old ]; then if [ ! -s commits ]; then exit fi mv commits commits.old cat commits.prep >> commits.prep.old && rm commits.prep fi if [ -s commits.old ]; then CVSROOT=/usr/local/repository export CVSROOT # local copy of checked out irc CVS cd /home/chopin/CVS cvs -Q co irc cat $WDIR/commits.prep.old | \ awk -F'[ ,]' '{D=$1; for (i=2;i> $WDIR/commits.old cd $WDIR mailx -s"master IRC CVS commits" irc-changes < commits.old && \ rm -f commits.old commits.prep.old else rm -f commits.old fi As you can see, the script uses local directory (here: /home/chopin/CVS) to do checkout of irc tree (this means you have to set this dir up, set up cvs to allow such checkouts etc.) and then some awk to change 'commits.prep' (taking the example from above) to series of: cvs diff -uN -r 1.187 -r 1.188 irc/doc/ChangeLog cvs diff -uN -r 1.8 -r .19 irc/doc/2.11-New cvs diff -uN -r 1.94 -r 1.95 irc/ircd/s_bsd.c which then are piped to ksh for execution and their output appended to the 'commits' log file, which then is simply mailed to whoever you want (here: local distrubution list 'irc-changes'). Of course this can be improved; it probably does not work well with different trees (or maybe not at all), I should take into the account the adding and removing of files, I could send every diff as separate attachment (using metamail perhaps), etc. etc. But it works and you can modify it to suit your needs. Happy coding!