dre*_*lax 5 cvs version-control commit pre-commit-hook
是否可以在CVS的预提交钩子中使用提交消息?CVS服务器正在远程运行,我使用它来访问它pserver.
理想情况下,如果文件通过过滤器或提交消息包含某些文本,我想允许提交.
我没有选择使用其他版本控制系统.
以下是一些有用的教程,供您阅读更多内容:
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
Run Code Online (Sandbox Code Playgroud)
# 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
Run Code Online (Sandbox Code Playgroud)
#/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;
Run Code Online (Sandbox Code Playgroud)
买者自负:我在没有测试的情况下写了大部分内容,所以我不能保证它有效,但它至少应该让你接近。
再次编辑,我刚刚意识到我最初是错的,您可以传递日志文件和提交的文件名以verifymsg使答案变得更简单。