2014-04-09 91 views
0

我有一個可用的Subversion Post Commit工作正常 - 我如何在用戶執行提交時所做的註釋中添加?如何將提交註釋添加到Subversion提交後鉤子

我的代碼是

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 

但我不知道如何從得到的消息提交。

感謝您的任何幫助和建議。

回答

0

您必須從svnlook info的輸出解析提交消息。 文檔:

打印作者,日期戳記,日誌消息大小(以字節爲單位)和日誌消息,後跟一個換行符。

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 
+0

沒關係,這是比較容易的方式... :)但也許還加上'-r $ REV'來電。 – mellow