How to conditionally send svn commit e-mail based on keywords for commit?

My VisualSVN works with svnnotify by sending an email notification via post-commit (general setup), but I would like not to send an email when certain keywords are included in the commit message , such as "#noemail", or something similar.

Does anyone have an example of what I can add to my post commit to view the commit message and prevent email from being sent if certain keywords exist?

Thanks!


FYI, here is an example of my current post-conceptual 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 - "
+3
2

, "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
+3

linux hooks/post-commit:

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

nosvnemail .

0

Source: https://habr.com/ru/post/1719991/


All Articles