在CVS预提交钩子中使用提交消息 [英] Use the commit message in a CVS pre-commit hook

查看:77
本文介绍了在CVS预提交钩子中使用提交消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Is it possible to use the commit message in a pre-commit hook in CVS? The CVS server is running remotely, and I access it using pserver.

理想情况下,我想允许提交如果文件通过过滤器,则提交消息中包含某些文本。

Ideally, I want to allow the commit if the files pass the filter or the commit message contains certain text.

我没有选择使用其他版本控制系统的信息。 / p>

I don't have a choice to use another versioning system.

推荐答案

以下是一些有用的教程,以了解更多信息:

Here are some useful tutorials to read more:

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)。如果您不知道,结帐清单 commitinfo 和 verifymsg都可以在以下目录的CVSROOT目录中找到您的存储库。我建议也将您编写为钩子的所有脚本也放置在该目录中,但这并不重要,因为您可以指定完整路径。另外,perl不是必需的,也不是必需的,对我来说,在以下例子中写一些简单的例子就很简单:

You can't do what you want with just one hook but you can use two hooks, commitinfo will let you verify the files themselves and verifymsg will let you verify the message. Both can be used to cancel the commit (the programs just need to exit with status 1). In case you weren't aware, checkoutlist, commitinfo and 'verifymsg' can all be found in the CVSROOT directory of your repository. I would recommend putting any scripts you write as hooks in that directory as well, but it doesn't really matter as you get to specify the full path. Also, perl is not necessary or required, just simple for me to write some (silly) examples in:

# these files will be automatically checked out for you
acceptable



verifymsg



verifymsg

# 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



可接受



acceptable

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

随手找回者:我大部分内容是在没有测试的情况下写下的,所以我可以不能保证它能正常工作,但它至少应该使您接近。

Caveat emptor: I wrote most of this off the top of my head with no testing so I can't guarantee it works but it should get you at least close.

再次编辑,我才意识到我原来错了,可以通过日志文件和提交到 verifymsg 的文件名都使答案相当简单。

Edit again, I just realized that I was originally wrong and you can pass both the logfile and the committed filenames to verifymsg making the answer quite a bit simpler.

这篇关于在CVS预提交钩子中使用提交消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆