开发者

How to conditionally send svn commit email, based on commit message keywords?

开发者 https://www.devze.com 2022-12-08 04:30 出处:网络
I\'ve got VisualSVN running with svnnotify sending notification email via post-commit (the common setup), but I\'d like to not send email when certain keywords are included in the commit message开发者

I've got VisualSVN running with svnnotify sending notification email via post-commit (the common setup), but I'd like to not send email when certain keywords are included in the commit message开发者_如何学C, such as "#noemail" or something similar.

Anyone have an example of what I can add to my post-commit hook to look at the commit message and prevent email from being sent if certain keywords exist?

Thanks!


FYI, here's an example of my current post-commit content:

set REPOS=%1
set REV=%2
set EMAILADDRESSES="example@example.com"
set OS=Windows_NT
set PATH=%PATH%;C:\Program Files\VisualSVN Server\bin\;C:\Perl\site\bin;C:\Perl\bin;

svnnotify --repos-path %REPOS% --revision %REV% --to %EMAILADDRESSES% -f svn@example.com --smtp smtp.example.com --subject-prefix "SVN - Rev: %%d - "


Here's the solution, using keyword "nosvnemail":

set REPOS=%1
set REV=%2
set EMAILADDRESSES="example@example.com"
set OS=Windows_NT
set PATH=%PATH%;C:\Program Files\VisualSVN Server\bin\;C:\Perl\site\bin;C:\Perl\bin;

svnlook log -r %2 %1 | FindStr "nosvnemail"

IF %ERRORLEVEL% EQU 0 GOTO SKIPEMAIL

svnnotify --repos-path %REPOS% --revision %REV% --to %EMAILADDRESSES% -f svn@example.com --smtp smtp.example.com --subject-prefix "SVN - Rev: %%d - "

:SKIPEMAIL

exit 0


For linux, the following hooks/post-commit will work:

REPOS="$1"
REV="$2"
SVNLOOK=$(which svnlook)

LOGMSG=$($SVNLOOK log -r $REV $REPOS)
if [[ $LOGMSG != nosvnemail* ]] ; then
    "$REPOS"/hooks/mailer.py commit "$REPOS" $REV "$REPOS"/mailer.conf
fi

the nosvnemail string must be first in the log message.

0

精彩评论

暂无评论...
验证码 换一张
取 消