代码之家  ›  专栏  ›  技术社区  ›  dreamlax

在CVS预提交挂钩中使用提交消息

  •  5
  • dreamlax  · 技术社区  · 16 年前

    是否可以在CVS中的预提交挂钩中使用提交消息?CVS服务器正在远程运行,我使用 pserver .

    我没有选择使用另一个版本控制系统。

    4 回复  |  直到 16 年前
        1
  •  4
  •   Rob Van Dam    16 年前

    以下是一些有用的教程,请阅读:

    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 , 委员会

    检查表

    # 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;
    

    买主警告:我在没有测试的情况下写下了大部分内容,所以我不能保证它能正常工作,但它至少能让你接近。

    ,我才意识到我原来是错的,您可以将日志文件和提交的文件名传递给 验证消息 让答案简单一点。

        2
  •  3
  •   lwho    16 年前

    这个 CVS::Trigger Perl模块似乎有一个 允许在不同触发器调用之间缓存值的功能。该页面明确提到将文件名从commitinfo传递到verifymsg,因此它可能有助于实现您想要的功能。

        3
  •  1
  •   Tom Duckering Sorin Antohi    16 年前

    verifymsg 归档 CVSROOT 目录您可以将其配置为调用可以验证签入注释内容的脚本。您可以通过返回非零来拒绝提交。

    默认的verifymsg文件包含更多详细信息。

        4
  •  0
  •   Brad    16 年前

    祝你好运