############################################################
# find_bug_fix.pl   
# Ver 0.1 (08/12, 2009)
# (C) 2009 Hirohisa AMAN <aman@computer.org>
#
# This script extracts CVS commit logs which seem to be 
# bug fixings, and output the following data in CSV format:
#
#  revision, date, author, status, #added lines, #deleted lines
#
#
# CVS のコミットログからバグフィックスに関係する
# と思われるコミットのみを抽出し，
# そのリビジョン番号，日付，著者，状態，追加行数，削除行数を
# カンマ区切りで出力する
#
#
#############################################################

$keyword = "defect|fix|bug";

# ** Modify $keyword variable **
#
# This script decides if a commit log is a bug fixing commit or not,
# with using a simple pattern matching (ignoreing the case).
# If one of specified keywords appears in a commit log, the commit
# is considered to be a bug fixinig commit.
#
# 【必須事項】
# バグフィックスと思われるキーワードを設定
# 大文字・小文字は区別されない
# （例） defect か fix か bug の場合
#        $keyword = "defect|fix|bug";

while($line = <>){
    chomp($line);
    if ( $line =~ /----------------------------/ ){
	$revision = "";
	$date = "";
    }
    elsif ( $line =~ /^revision / && $revision eq "" ){
	split(/ /, $');
	$revision = $_[0];
    }
    elsif ( $line =~ /^date: / && $date eq "" ){
        split(/[\s;]+/, $'); 
	$date = $_[0] . " " . $_[1];
	$author = $_[3];
	$state = $_[5];
	$add = int($_[7]);
	$del = int($_[8]);
    }
    elsif ( $line =~ /(^|\W)($keyword)\W/i ){
	print "$revision,\"$date\",$author,$state,$add,$del\n";
    }
}
