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

拥有回忆 提交于 2019-12-05 17:36:26

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!