Warning: Illegal string offset 'region' in /home/mhd-01/www.gabcicala.it/htdocs/wp-content/plugins/mygeopositioncom-geotags-geometatags/mygeopositioncom-geotags-geometatags.php on line 386

Warning: Illegal string offset 'placename' in /home/mhd-01/www.gabcicala.it/htdocs/wp-content/plugins/mygeopositioncom-geotags-geometatags/mygeopositioncom-geotags-geometatags.php on line 390

Warning: Illegal string offset 'position' in /home/mhd-01/www.gabcicala.it/htdocs/wp-content/plugins/mygeopositioncom-geotags-geometatags/mygeopositioncom-geotags-geometatags.php on line 394

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


Warning: Illegal string offset 'addMap' in /home/mhd-01/www.gabcicala.it/htdocs/wp-content/plugins/mygeopositioncom-geotags-geometatags/mygeopositioncom-geotags-geometatags.php on line 639

Warning: Illegal string offset 'position' in /home/mhd-01/www.gabcicala.it/htdocs/wp-content/plugins/mygeopositioncom-geotags-geometatags/mygeopositioncom-geotags-geometatags.php on line 561

Warning: Illegal string offset 'position' in /home/mhd-01/www.gabcicala.it/htdocs/wp-content/plugins/mygeopositioncom-geotags-geometatags/mygeopositioncom-geotags-geometatags.php on line 603

Nel dover gestire dei progetti web utilizzando SVN (SubVersion) è utile abilitare un hook (il post-commit in particolare) che faccia un update del progetto web e in particolare della copia che sarà visibile via HTTP formulando la URL del progetto.
Un primo script è il seguente che in sostanza fa un update per ogni commit del repository.

host:~$ cat /var/local/projectsvn/hooks/post-commit
#!/bin/sh
/usr/bin/svn update /var/www/htdocs/projectsvn/htdocs –username user –password password

Un altro script, che io preferisco, invece si occupa di fare l’update delle singole directory che vengono aggiornate mediante la utility svnlook ed è il seguente:

host:~$ cat /var/local/projectsvn/hooks/post-commit
#!/bin/sh
/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

dove la directory /var/local/projectsvn sarebbe il repository del progetto, mentre la directory /var/www/htdocs/projectsvn/htdocs/ sarebbe la directory della cosiddetta working copy. In soldoni non viene fatto l’update ricorsivo del progetto ma solo delle singole directory che restituisce la parte /usr/bin/svnlook dirs-changed /var/local/projectsvn.

In ultimo può essere comodo controllare che lo script sia funzionante magari implementando anche l’invio di una mail. Come ad esempio con il seguente script:

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

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
#END Invio mail

Technorati Tags: , ,

About the Author: glycerin