以下是一些有用的教程,供您阅读更多内容:
http://durak.org/sean/pubs/software/cvsbook/The-commitinfo-And-loginfo-And-rcsinfo-Files.html
http://durak.org/sean/pubs/software/cvsbook/The-verifymsg-And-rcsinfo-Files.html#The-verifymsg-And-rcsinfo-Files
你不能只用一个钩子做你想做的事,但你可以使用两个钩子,commitinfo
会让您验证文件本身并verifymsg
会让您验证该消息。两者都可以用来取消提交(程序只需以状态 1 退出)。如果你不知道,checkoutlist
, commitinfo
和“verifymsg”都可以在存储库的 CVSROOT 目录中找到。我建议将您编写为钩子的任何脚本也放在该目录中,但这并不重要,因为您可以指定完整路径。另外,perl 不是必需的或必需的,对我来说只是简单地编写一些(愚蠢的)示例:
结账清单
# these files will be automatically checked out for you
acceptable
验证消息
# specifies which file to run as hook, %l is filename of log message
# bar$ /path/to/repo/CVSROOT/verify_ends_in_bar %l
DEFAULT /path/to/repo/CVSROOT/acceptable %l %s
可以接受
#/usr/bin/perl -w
use strict;
use warnings;
# this would be simpler if cvs passed sane arguments
my ($logfile, $dir, @files) = @ARGV;
my $grep = `grep -i 'accept liability' $logfile`;
exit 0 if $grep;
my $found = 0;
foreach my $file (@files) {
my $path = join '/', $dir, $file;
die "Can't find file $path" if ! -e $path;
my $grep = `grep -i 'evidence of any deliberation' $path`;
$found++ if $grep;
}
die "You must accept liability or show evidence of deliberation" if $found < @files;
买者自负:我在没有测试的情况下写了大部分内容,所以我不能保证它有效,但它至少应该让你接近。
再次编辑,我刚刚意识到我最初是错的,你可以将日志文件和提交的文件名传递给verifymsg
使答案变得更加简单。