如何让 Subversion (SVN) 在签到时发送电子邮件?

发布于 2024-07-04 03:41:57 字数 167 浏览 15 评论 0 原文

我一直发现签入(提交)邮件对于跟踪其他人在代码库/存储库中所做的工作非常有用。 如何设置 SVN 在每次提交时通过电子邮件发送通讯组列表?

我在 Windows 上运行客户端,在 Linux 上运行 Apache Subversion 服务器。 不过,下面针对不同平台的答案可能对其他人有用。

I've always found checkin (commit) mails to be very useful for keeping track of what work other people are doing in the codebase / repository. How do I set up SVN to email a distribution list on each commit?

I'm running clients on Windows and the Apache Subversion server on Linux. The answers below for various platforms will likely be useful to other people though.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(16

塔塔猫 2024-07-11 03:41:57

检查svn-mod-email包="nofollow">这里svn-mod-email 是一个强大的 SVN 电子邮件通知管理工具,以 Debian 存档形式提供。 它易于安装、配置和使用。

Check the svn-mod-email package described here. The svn-mod-email is a powerful tool for SVN email notifications management that is delivered as a Debian archive. It's easily to install, configure and use.

奈何桥上唱咆哮 2024-07-11 03:41:57

您可以使用 buildbot。 该工具可以在签到时执行任意操作。 它是一个功能齐全的持续集成系统,但如果您只需要电子邮件,它当然可以处理。 它具有适用于包括 SVN 在内的各种 SCM 的插件。

You could use buildbot. It's a tool that can take arbitrary action whenever a check-in occurs. It's a full featured continuous integration system but if you just want emails it can certainly handle that. It has plug-ins for a variety of SCMs including SVN.

離人涙 2024-07-11 03:41:57

在特定 subversion 分支的“hooks”目录中,有 9 个模板文件可以帮助您入门。

关键点:subversion 在重命名之前不会执行任何文件。 要让 post-commit.tmpl 在 unix 下执行,请将其重命名为“post-commit”。 在 Windows 下,将其重命名为“post-commit.bat”或“post-commit.exe”。 如果文件名为“post-commit.tmpl”或“post-commit.sh”等,Subversion 将不会执行该文件。

另外,请确保该文件可由运行 subversion 的同一用户执行。

In the "hooks" directory of your specific subversion branch there are 9 template files to get you started.

Key point: subversion will not execute any of the files until they are renamed. To get post-commit.tmpl to execute under unix, rename it "post-commit". Under Windows, rename it to "post-commit.bat" or "post-commit.exe". Subversion will not execute the file if it is named "post-commit.tmpl" or "post-commit.sh" or the like.

Also, make sure that the file is executable by the same user that runs subversion.

请帮我爱他 2024-07-11 03:41:57

我使用类似于此的提交后脚本 一个

它会发送一封漂亮的 HTML 电子邮件。 我对其进行了一些更新,其中以红色突出显示了已删除的代码,并以蓝色突出显示了添加的代码。

I use a post-commit script similar to this one.

It's sends a nice HTML email. I updated it some where it highlights code that was removed in red and highlights code that was added in blue.

却一份温柔 2024-07-11 03:41:57

我在 Linux 服务器上分 3 步完成了此操作:

  1. 创建邮件列表 ( [email protected])并将人员添加到列表中。

  2. 编辑/path_to_your_svn/svn/hooks/svn-notify/mailer.conf

  3. 将此行添加到您的 /path_to_your_svn/svn/hooks/post-commit 文件中:
    /path_to_your_svn/svn/hooks/svn-notify/mailer.py commit "$REPOS" "$REV" /path_to_your_svn/svn/hooks/svn-notify/mailer.conf

I did it on Linux server in 3 steps:

  1. Create a mailing list ([email protected]) and add people to the list.

  2. Edit /path_to_your_svn/svn/hooks/svn-notify/mailer.conf

  3. Add this line to your /path_to_your_svn/svn/hooks/post-commit file:
    /path_to_your_svn/svn/hooks/svn-notify/mailer.py commit "$REPOS" "$REV" /path_to_your_svn/svn/hooks/svn-notify/mailer.conf
自控 2024-07-11 03:41:57

什么平台?

在 Mac OS X 上,我安装了 msmtp 并在存储库中的钩子下创建了一个提交后脚本。 需要为 svn(或 www)用户设置 .msmtprc 文件。

REPOS="`echo $1 | sed 's/\/{root of repository}//g'` "
REV="$2"
MSG=`/usr/local/bin/svn log -v -r HEAD https://localhost$REPOS`

/usr/local/bin/msmtp {list of recipients} <<EOF
Subject: SVN-Commit $REPOS#$REV
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8Bit

$MSG
EOF

使 {root of repository}{list ofrecipients} 专门满足您的需求。 注意我使用了 UTF-8,因为瑞典有一些特殊字符 (åäö)。

What platform?

On Mac OS X I have installed msmtp and created a post-commit script under hooks in the repository. A .msmtprc file needs to be setup for the svn (or www) user.

REPOS="`echo $1 | sed 's/\/{root of repository}//g'` "
REV="$2"
MSG=`/usr/local/bin/svn log -v -r HEAD https://localhost$REPOS`

/usr/local/bin/msmtp {list of recipients} <<EOF
Subject: SVN-Commit $REPOS#$REV
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8Bit

$MSG
EOF

Make {root of repository} and {list of recipients} specific for your needs. Note I have used UTF-8 because we have some special characters here in Sweden (åäö).

知你几分 2024-07-11 03:41:57

Subversion 源代码中包含一个用 Perl 编写的(大型)示例(可以是 在此处查看)。

There is a (large) example written in Perl included in the Subversion source (it can be viewed here).

记忆で 2024-07-11 03:41:57

还有 SVNMailer,它可以在 Linux 上运行。

Also SVNMailer, which works on Linux.

想挽留 2024-07-11 03:41:57

这里有一个关于提交后挂钩的相关问题。 就我个人而言,我更喜欢将消息发送到可以从中获取 RSS 源的地方,因为每次提交一封电子邮件都会很快使我的收件箱超载。

There's a related question here on post-commit hooks. Personally, I prefer to send a message to something I can get an RSS feed from, as an email-per-commit would overload my inbox pretty quickly.

鸩远一方 2024-07-11 03:41:57

在 RSS 上支持 @Matt Miller饲料。

有一个名为 WebSVN 的有用工具,它提供每个存储库和单个分支/标签/文件夹的 RSS 提要以及完整提交消息。 它也是一个很棒的网络界面,可以快速查看文件历史记录和提交/差异,而无需运行更新并打开您选择的编辑器。

Seconding @Matt Miller on RSS feeds.

There's a useful tool called WebSVN that offers RSS feeds of every repository and individual branches/tags/folders with full commit messages. It's also a great web interface for quickly looking at file histories and commits/diffs without having to run an update and open your editor of choice.

苏佲洛 2024-07-11 03:41:57

正如其他人所说,“什么平台”。 在 Windows 上,我使用“blat”(一个免费的命令行 SMTP 邮件程序)以及一个提交后文件和另一个批处理文件来执行此操作。

提交后看起来像这样:(只是调用另一个批处理文件)

 call d:\subversion\repos\rts\hooks\mail %1 %2

并且mail.bat看起来像这样:

copy d:\subversion\repos\RTS\hooks\Commitmsg.txt %temp%\commit.txt
copy d:\subversion\repos\RTS\hooks\subjbase.txt %temp%\subject.txt
svnlook info -r %2 %1 >> %temp%\commit.txt
echo Revision %2 >> %temp%\commit.txt
svnlook changed -r %2 %1 >> %temp%\commit.txt
svnlook author -r %2 %1 >> %temp%\subject.txt
c:\utils\blat %temp%\commit.txt -t <[email protected]> -sf %temp%\subject.txt -server ServerName -f "SVN Admin <[email protected]>" -noh2

编写SVN钩子时最大的问题是你可能基本上没有环境设置 - 没有exe路径,没有临时路径等.不过也许这在最近的 SVN 版本中有所改进。

As someone else said, 'what platform'. On Windows I've used 'blat', which is a freebie command line SMTP mailer to do this, along with a post-commit and another batch file.

The post commit looks like this: (Just calls another batch file)

 call d:\subversion\repos\rts\hooks\mail %1 %2

And mail.bat looked like this:

copy d:\subversion\repos\RTS\hooks\Commitmsg.txt %temp%\commit.txt
copy d:\subversion\repos\RTS\hooks\subjbase.txt %temp%\subject.txt
svnlook info -r %2 %1 >> %temp%\commit.txt
echo Revision %2 >> %temp%\commit.txt
svnlook changed -r %2 %1 >> %temp%\commit.txt
svnlook author -r %2 %1 >> %temp%\subject.txt
c:\utils\blat %temp%\commit.txt -t <[email protected]> -sf %temp%\subject.txt -server ServerName -f "SVN Admin <[email protected]>" -noh2

The biggest gotcha in writing SVN hooks is that you might have basically NO environment set-up - no exe path, no temp path, etc. Though maybe that's improved in more recent SVN builds.

燃情 2024-07-11 03:41:57

1) 使用 sudo apt-get 在 svn 服务器上安装 svnnotify

2) 使用存储库的 post-commit 挂钩(阅读 svn 网站上的 post-commit 挂钩)

3) 打开 post-commit 挂钩文件并粘贴以下代码以发送电子邮件使用 smtp 服务器。
使用 smtp 非常简单,因为您不需要配置 sendmail。

4)确保\(换行符)之后没有多余的空格。

#!/bin/sh

REPOS="$1"
REV="$2"
TO="[email protected]" # who will receive the notifications
FROM="[email protected]" # what will be in "FROM" fields


 /usr/bin/svnnotify \

--repos-path "$REPOS" \
--revision "$REV" \
--to $TO \
--from $FROM \
--reply-to $FROM \
--smtp "YOUR.SMTP.MAIL.COM" \
--subject-prefix "[svn commit]" \
--attach-diff -a \
--header 'Message generated on Subversion Check-in.' \
--footer 'OpenSource Team. ' \
--svnlook "/usr/local/bin/svnlook" \
--handler HTML::ColorDiff # make diff pretty

1) Install svnnotify on a svn server using sudo apt-get

2) Use post-commit hook of your repo (read on post-commit hooks on svn website)

3) Open post-commit hook file and paste following code to send an email using smtp server.
Using smtp is straight forward since you don't need to configure sendmail.

4) Make sure after \ (line break) you don't have an extra space.

#!/bin/sh

REPOS="$1"
REV="$2"
TO="[email protected]" # who will receive the notifications
FROM="[email protected]" # what will be in "FROM" fields


 /usr/bin/svnnotify \

--repos-path "$REPOS" \
--revision "$REV" \
--to $TO \
--from $FROM \
--reply-to $FROM \
--smtp "YOUR.SMTP.MAIL.COM" \
--subject-prefix "[svn commit]" \
--attach-diff -a \
--header 'Message generated on Subversion Check-in.' \
--footer 'OpenSource Team. ' \
--svnlook "/usr/local/bin/svnlook" \
--handler HTML::ColorDiff # make diff pretty
初熏 2024-07-11 03:41:57

VisualSVN Server 有有用的提交电子邮件通知挂钩 VisualSVNServerHooks.exe。 它支持彩色差异,并且仅当提交影响某些存储库路径时才可以发送提交通知。

请参阅“在 VisualSVN 服务器中配置电子邮件通知”

VisualSVN Server has useful commit e-mail notification hook VisualSVNServerHooks.exe. It supports colored diffs and can send commit notifications only when commit affects certain repository path.

See "Configuring Email Notifications in VisualSVN Server".

愁杀 2024-07-11 03:41:57

查看独立的 Subversion Notify 工具(仅限 Windows!)
它可以在提交时发送电子邮件等等!

Have a look at the standalone Subversion Notify tool (Windows only!)
It can do emailing on commit and also much more!

⊕婉儿 2024-07-11 03:41:57

您需要熟悉 存储库挂钩,特别是 提交后挂钩

You'll want to familiarize yourself with repository hooks, particularly the post-commit hook.

痴者 2024-07-11 03:41:57

您使用 提交后钩子

下面是一个示例 Ruby 脚本,它在每次提交后发送一封电子邮件: commit-email.rb

You use the post-commit hooks.

Here's a sample Ruby script that sends an email after each commit: commit-email.rb

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文