Source

erc / mkChangeLog.upstream

#! /bin/zsh
## Oh, this is -*- shell-script -*-!
##
## Adapted from utils/mkChangelog from the shoop CVS
## Probably written by doogie
##
## Hacked for his own needs by Gergely Nagy <algernon@debian.org>

set -e

if test -e CVS/Root; then
	CVS_ROOT=${CVS_ROOT:-`sed -e "s,/,\\\\\/,g" -e "s,^:[^:]*:[^:]*:,," <CVS/Root`\\/}
fi
RCS2LOG_OPTIONS=${RCS2LOG_OPTIONS:--v}
CHLOG=${1:-ChangeLog}
[ $# -gt 1 ] && shift
AUTHORS=${AUTHORS:-AUTHORS}
RCS2LOG=${RCS2LOG:-rcs2log}

NEWLINE="
"

if test -e ${AUTHORS}; then
	LIST="$(grep '^\([^<]*\)[ 	]\+<\([^>]*\)>[ 	]\+\(.*\)' <${AUTHORS})"
	NAMES="$(echo ${LIST} | sed -e 's,^\([^<]*\)[ 	]\+.*,\1,g' -e 's,[ 	]\+$,,g')${NEWLINE}"
	ADDYS="$(echo ${LIST} | sed -e 's,^[^<]*[ 	]\+<\([^>]\+\)>.*,\1,g')${NEWLINE}"
	LOGINS="$(echo ${LIST} | sed -e 's,^.*[ 	]\([^ 	]\+\)$,\1,g')${NEWLINE}"
	ARGS=""
	for i in $(seq 1 ${(ws:\n:)#${(f)NAMES}}); do
			ARGS="${ARGS} -u \"${${(f)LOGINS}[$i]}:${${(f)NAMES}[$i]}:${${(f)ADDYS}[$i]}\"";
	done
fi

eval ${RCS2LOG} ${RCS2LOG_OPTIONS} "${ARGS}" $* | \
awk "
/\t\* /{
	split(\$0,A,/:/);
	count=split(A[1],B,/, /);
	first=1;
	len=0
	for(C = 1; C <= count; C++) {
		if(!first) {
			printf \", \";
			len += 2;
		}
		if ( len > 65 ) {
			printf \"\n\t  \";
			len=0
		}
		sub(/$CVS_ROOT/,\"\",B[C]);
		printf \"%s\", B[C];
		len += length(B[C]);
		first=0
	}
	cnt=0;
	for (i in A) {
		if (cnt>=1)
			printf \":%s\", A[i];
		cnt++;
	}
	printf \"\n\";
	printed=1
}
{
	if(printed != 1)
		print;
	printed=0
}
" | sed -e 's,CVS: \-\+$,,g' > ${CHLOG}

exit 0