如何将提交注释添加到Subversion post-commit钩子

时间:2014-04-09 16:12:36

标签: svn post-commit svn-hooks post-commit-hook

我有一个正在运行的Subversion Post Commit工作正常 - 如何添加执行提交的用户所做的评论?

我的代码是

REPOS="$1"
REV="$2"

AUTHOR="$(svnlook author -r $REV $REPOS)"

mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf

# Script to send simple email when SVN is updated

# email subject
SUBJECT="[Project Name goes here] - new commit made in Subversion"

# Email To 
EMAIL="[email addresses go here]"

# Date and time
DATE="$(date)"

# Email text/message
EMAILMESSAGE="/tmp/buildingcontrolmessage.txt"
echo "The commit happened: " $DATE > $EMAILMESSAGE
echo "Repository: " $1 >> $EMAILMESSAGE
echo "Reveision: " $2 >> $EMAILMESSAGE
echo "The commit was made by: $AUTHOR"  >> $EMAILMESSAGE

# send an email using /bin/mail

/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

我只想在电子邮件中添加一行说:

echo "Comment: $MSG"  >> $EMAILMESSAGE

但我不确定如何从提交中获取消息。

感谢您提供任何帮助和建议。

2 个答案:

答案 0 :(得分:1)

以防其他人想要这样做 - 这就是我最后所做的事情:

REPOS="$1"
REV="$2"
AUTHOR="$(svnlook author -r $REV $REPOS)"
MESSAGE="$(svnlook log $REPOS)"


mailer.py commit "$REPOS" "$REV" /path/to/mailer.conf

# Script to send simple email when SVN is updated

# email subject
SUBJECT="New commit made in Subversion"

# Email To ?
EMAIL="[email address or addresses]"

# Date and time
DATE="$(date)"

# Email text/message
EMAILMESSAGE="/tmp/emailmessagemessage.txt"
echo "The commit happened: " $DATE > $EMAILMESSAGE
echo "Repository: " $1 >> $EMAILMESSAGE
echo "Reveision: " $2 >> $EMAILMESSAGE
echo "The commit was made by: $AUTHOR"  >> $EMAILMESSAGE
echo "Comment: $MESSAGE" >> $EMAILMESSAGE

# send an email using /bin/mail
/bin/mail -s "$SUBJECT" "$EMAIL" < $EMAILMESSAGE

答案 1 :(得分:0)

您必须解析svnlook info输出中的提交消息。 文档:

  

打印作者,日期戳,日志消息大小(以字节为单位)和日志消息,后跟换行符。