#! /bin/sh # -*- mode: shell-script -*- # # updatechangelog 1.2 # # Copyright (C) 2003 Elmar Hoffmann # # Automatically generate ChangeLog on CVS commit using cvs2cl. # # You need to have RCS from http://www.gnu.org/software/rcs/ # and cvs2cl from http://www.red-bean.com/cvs2cl/ installed # in the PATH used below. # # Assuming foobar being your projects top-level dir below $CVSROOT, # ie. you want to create $CVSROOT/foobar/ChangeLog on commit and # you installed this script to /usr/local/bin/, add the following # line to $CVSROOT/CVSROOT/loginfo: # ^foobar /usr/local/bin/updatechangelog %s # # If you however commited this script into $CVSROOT/CVSROOT/, use the # following line instead: # ^foobar $CVSROOT/CVSROOT/updatechangelog %s # Do not forget to add it to $CVSROOT/CVSROOT/checkoutlist in this case! # # Download latest version at http://www.elho.net/dev/updatechangelog # # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # CVS2CLFLAGS="--separate-header --no-wrap --utc --usermap $CVSROOT/CVSROOT/users" export PATH='/usr/sbin:/usr/bin:/sbin:/bin' test "x$1" = "x" && exit 0 # avoid recursion expr "$1" : '[^ ]* ChangeLog' >/dev/null && exit 0 # get top-level directory and relative path to get there fulldir=`expr substr "$1" 1 \( index "$1" " " - 1 \)` index=`expr index "$fulldir" "/"` if [ $index -gt 0 ]; then reldir=".." dir=`dirname "$fulldir"` while expr index "$dir" "/" >/dev/null; do reldir="$reldir/.." dir=`dirname $dir` done else dir="$fulldir" reldir="." fi # run in background to avoid deadlock ( cd "$reldir" test -f ChangeLog && rm -f ChangeLog && touch ChangeLog >/dev/null 1>&2 cvs update ChangeLog >/dev/null ( cd "$CVSROOT/$dir" find -name '*,v' -print | sed 's#^\./\(.*\),v$#\1#' | \ xargs --no-run-if-empty rlog ) | \ cvs2cl --stdin --ignore ChangeLog $CVS2CLFLAGS >/dev/null rm -f ChangeLog.bak >/dev/null 1>&2 cvs commit -m 'automatic ChangeLog regeneration' ChangeLog >/dev/null ) &