<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Hervé Marcy&#039;s blog &#187; Subversion</title>
	<atom:link href="http://www.hmarcy.com/tag/subversion/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.hmarcy.com</link>
	<description>Linux, Free Software, Europe, Leadership…</description>
	<lastBuildDate>Sun, 18 Jul 2010 06:04:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Automatic commit of a Subversion repository</title>
		<link>http://www.hmarcy.com/2008/09/automatic-commit-of-a-subversion-repository/</link>
		<comments>http://www.hmarcy.com/2008/09/automatic-commit-of-a-subversion-repository/#comments</comments>
		<pubDate>Tue, 16 Sep 2008 19:20:12 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[Subversion]]></category>

		<guid isPermaLink="false">http://hmarcy.com/?p=3</guid>
		<description><![CDATA[This is a short script which allows an automatic update of a subversion repository on Linux : Create a log-directory into your Subversion repository $mkdir logs and save the following script into the repository as svn_cron.sh #!/bin/bash # # Variable REPOS is the path to the repository on the server REPOS=. echo &#8220;&#8221; date +&#8221;%B [...]]]></description>
			<content:encoded><![CDATA[<p>This is a short script which allows an automatic update of a subversion repository on Linux :</p>
<p>Create a log-directory into your Subversion repository</p>
<p>$mkdir logs</p>
<p>and save the following script into the repository as svn_cron.sh</p>
<p>#!/bin/bash<br />
#<br />
# Variable REPOS is the path to the repository on the server</p>
<p>REPOS=.<br />
echo &#8220;&#8221;<br />
date +&#8221;%B %d %Y&#8221;</p>
<p>test $# = 0 || ( echo &#8220;Please enter the path to the local copy&#8221;; exit 1 )</p>
<p>cd $1 2&gt;&amp;1 &gt;/dev/null || ( echo &#8220;$1 does not exist&#8221;; exit 2 )</p>
<p>/usr/local/bin/svn info 2&gt;&amp;1 &gt;/dev/null|| ( echo &#8220;$1 is not a working copy&#8221;; exit 3 )</p>
<p>if [ `/usr/local/bin/svn update $1 | sed -n "/^C/p" | wc -l` -ne 0 ]<br />
then</p>
<p># Collects all files and directorys which are to add on the repository<br />
/usr/local/bin/svn status | sed -n &#8220;/^\??*/p&#8221; | sed &#8220;s/^\? *//g&#8221; &gt; $REPOS/logs/toadd</p>
<p># Collects all files and directorys which are to delete on the repository<br />
/usr/local/bin/svn status | sed -n &#8220;/^\!?*/p&#8221; | sed &#8220;s/^\! *//g&#8221; &gt; $REPOS/logs/todelete*//g&#8221; &gt; $REPOS/logs/todelete</p>
<p># Add and delete Subversion actions<br />
cat $REPOS/logs/todelete | while read line; do /usr/local/bin/svn delete &#8220;${line}&#8221;; done<br />
cat $REPOS/logs/toadd | while read line; do /usr/local/bin/svn add &#8220;${line}&#8221;; done</p>
<p># SVN commit in order to save the changes with a log message<br />
if !(/usr/local/bin/svn commit -m &#8220;Daily commit for changes done directly on the server&#8221;)<br />
then echo &#8220;A problem has occured during the commit&#8221;<br />
exit 3<br />
fi</p>
<p>else<br />
echo &#8220;Problem with the daily update, there may be a conflict within the following files  \! &#8221;</p>
<p># Displays the files which are currently in conflict<br />
svn status $1<br />
exit 4<br />
fi<br />
exit 0</p>
<p>Then edit the crontab</p>
<p>$crontab -e</p>
<p>or if you want the uploads to be done by another user</p>
<p>$crontab -e -u username</p>
<p>Of course, the user must have write permission to write on the logs directory.</p>
<p>Put the following lines at the end of the file</p>
<p>##Automatic update of the Subversion repository every day at 0:00<br />
0  0   * * *  /path_to_your_repository/svn_cron.sh /path_to_your_local_copy &gt;&gt; /path_to_your_repository/logs/script_cron</p>
<p>And that&#8217;s it !</p>
]]></content:encoded>
			<wfw:commentRss>http://www.hmarcy.com/2008/09/automatic-commit-of-a-subversion-repository/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
