更改特定文件时,SVN将提交提交钩到电子邮件用户 [英] SVN post commit hook to email user when a particular file is changed

查看:155
本文介绍了更改特定文件时,SVN将提交提交钩到电子邮件用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想添加一个后提交钩子,以便如果用户将更改提交到特定文件中,则会通过电子邮件通知我.

I would like to add a post commit hook so that if a user commits changes to a particular file, I will be notified by email.

有没有人看过这样的例子,或者有可能吗?

Has anyone seen an example of this, or is it possible?

我之前已经设置了一个预提交钩子,但这是我所知的范围.

I have set up a pre commit hook before, but that's limit of my knowledge.

推荐答案

我有一个 post-完全执行此操作的github 上的commit hook,它允许用户(而不是管理员说出他们正在监视的文件是什么,以及这些更改应发送到的电子邮件地址).

I have a post-commit hook on github that does exactly this, and it allows the users (instead of the administrator to say what files they're watching for changes, and what email addresses these changes should be sent to.

您可以将其与我的 pre-commit-kitchen-sink钩,以确保用户只能编辑自己的监视文件.钩子脚本使用Perl,但是它们不需要任何非标准模块,因此非常易于使用.

You can combine this with my pre-commit-kitchen-sink hook to make sure that users can only edit their own watch files. The hook scripts use Perl, but they don't require any non-standard modules, so they're pretty easy to use.

每个用户都有自己的监视文件,语法非常简单:

Each user gets their own watch file, the syntax is pretty easy:

mail = david@gmail.com
file =**/build.xml
match = [Mm]akefile

mail行是我要通过电子邮件发送通知的位置.我可以有多个. file是我正在查看的文件的全局表达式(在表达式的前部和后部固定). match行与此类似,并使用了未锚定的Perl正则表达式.

The mail line is where I want to email the notice. I can have multiple ones. The file is a glob expression (anchored at the front and back of the expression) of what files I'm watching. The match line is similar, and uses a Perl regular expression which is unanchored.

监视文件存储在Subversion存储库中您指定的目录中.这意味着用户可以设置自己的手表.您可以使用我的pre-commit-kitchen-sink钩子来防止用户更改其他用户的监视文件:

The watch files are stored in the Subversion repository in a directory you specify. This means that the users can set their own watches. You can use my pre-commit-kitchen-sink hook to prevent users from changing other users' watch files:

[file You are only allowed to change their own watch files]
file =/watchfiles/**
permission = read-only
users = @ALL

[file You are only allowed to change their own watch files]
file = /watchfiles/<USER>.cfg
permission = read-write
users = @ALL

<USER>字符串被解释为用户的ID.

The <USER> string is interpreted as the user's ID.

如果我想将提交后提交钩子设置为多个文件,可以设置吗?像file = ab/build.xml,bb/cs.txt,cc/.等.我只想通过电子邮件通知这些文件

If I want to set post commit hook to more than one files, so can I set? like file = ab/build.xml, bb/cs.txt, cc/. etc I want notification by email of these files only

您可以为每种模式添加一行:

You can put a line in for each pattern:

 email = my@email.com
 file = **/ab/build.xml
 file = **/bb/cs.txt
 file = **/cc/*.*

请记住,file全局模式已锚定在存储库的根目录中(使用/作为根目录),因此您需要指定完整路径,或使用**/指定该文件的任何路径.

Remember that file glob pattern is anchored to the root of the repository (using / as the root) so you need to specify the full path, or use the **/ to specify any path to that file.

这篇关于更改特定文件时,SVN将提交提交钩到电子邮件用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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