SVN: una seconda implementazione del post-commit per progetti web

Una seconda implementazione dello script di post-commit è stata implementata causa bug trovati successivamente e quindi sono stato costretto a rivedere anche lo script per facilitare il bug-fixing.

Di seguito lo script nelle sue varie parti:

#!/bin/sh

#cd /var/www/htdocs/projectsvn/htdocs
#/usr/bin/svnlook dirs-changed /var/local/projectsvn |/usr/bin/xargs /usr/bin/svn up -N {} –username user –password password >> /var/tmp/svn.mail.01.$$$
#error_code=`/bin/echo “$?”`
#/bin/echo “Error_code: $error_code” >> /var/tmp/svn.mail.01.$$$
#if [ “$error_code” != 0 ]; then
#    /bin/echo “[Error] ERROR on $LINENO” >> /var/tmp/svn.mail.01.$$$
#    #exit 1
#fi

### update su directory
##/usr/bin/svnlook dirs-changed /var/local/projectsvn| /usr/bin/awk ‘{print “/var/www/htdocs/projectsvn/htdocs/”$1}’ |/usr/bin/xargs /usr/bin/svn up -N –username user –password password
#cd /var/www/htdocs/projectsvn/htdocs
#/usr/bin/svnlook dirs-changed /var/local/projectsvn| /usr/bin/xargs /usr/bin/svn up -N –username user –password password >> /var/tmp/svn.mail.01.$$$
#error_code=`/bin/echo “$?”`
#/bin/echo “Error_code: $error_code” >> /var/tmp/svn.mail.01.$$$
#if [ “$error_code” != 0 ]; then
#    /bin/echo “[Error] ERROR on $LINENO” >> /var/tmp/svn.mail.01.$$$
#    #exit 1
#fi
### END update su directory

### update su singolo file
/usr/bin/svnlook changed /var/local/projectsvn| /bin/sed “s/^….//” | /usr/bin/awk ‘{print “/var/www/htdocs/projectsvn/htdocs/”$1}’ |/usr/bin/xargs /usr/bin/svn up –username user –password password >> /var/tmp/svn.mail.01.$$$
error_code=`/bin/echo “$?”`
/bin/echo “Error_code: $error_code” >> /var/tmp/svn.mail.01.$$$
if [ “$error_code” != 0 ]; then
    /bin/echo “[Error] ERROR on $LINENO” >> /var/tmp/svn.mail.01.$$$
    #exit 1
fi
### END update su singolo file

/bin/echo “—————————————————-” >> /var/tmp/svn.mail.01.$$$

#Invio mail
AUTHOR=`/usr/bin/svnlook author    /var/local/projectsvn`;

echo “Upgrade to revision by $AUTHOR” >> /var/tmp/svn.mail.01.$$$
/usr/bin/svnlook changed /var/local/projectsvn >> /var/tmp/svn.mail.01.$$$

mail -s “Projectsvn update from $AUTHOR” user@dominio.it -a “From: svn update <userfrom@dominio.it>” -a “Return-Path: userfrom@dominio.it” < /var/tmp/svn.mail.01.$$$

if [ -e /var/tmp/svn.mail.01.$$$ ]; then
    rm -f /var/tmp/svn.mail.01.$$$
fi

In quest’ultimo caso sono stati inseriti dei codici di controllo al fine di controllare che la procedura vada a buon fine.
Quale ad esempio la parte inerente l’error_code. Tutte queste parti possono essere disattivate in un secondo tempo, insieme all’invio della mail.

Technorati Tags: , ,

About the Author: glycerin