<?xml version="1.0" encoding="UTF-8" ?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
  <title>Latest snippets tagged subversion</title>
  <link rel="alternate" href="http://snippets.prendreuncafe.com/snippets/tagged/subversion/order_by/date"></link>
  <id>http://snippets.prendreuncafe.com/snippets/tagged/subversion/order_by/date</id>
  <updated>2008-10-21T20:41:09Z</updated>
  <author>
    <name>Symfony</name>
    <author_email>noreply@symfony-project.com</author_email>
  </author>
<entry>
  <title>SVN based CSS/JS Caching trick</title>
  <link href="http://snippets.prendreuncafe.com/snippet/96"></link>
  <updated>2008-10-21T20:41:09Z</updated>
  <id>96</id>
  <summary type="html">You want to be sure client (browser or real one) uses the very last css/js file everytime you update svn repository.

Here's my proposition :

__Make a sfSVN.class.php__

[code php]
&lt;?php
/**
 *  sfSVN : sf+SVN based CSS/JS caching trick
 *
 * @author [MA]Pascal &lt;pborreli@sqli.com&gt;
 */
class sfSVN
{
    /**
     * returns the last revision number
     *
     * @return integer
     */
    public static function getHeadRevision ()
    {
        if (! file_exists($file = sfConfig::get('sf_root_dir') . DIRECTORY_SEPARATOR . '.svn/entries')) {
            return date('Ymd');
        }
        $svn = file($file);
        return isset($svn[3]) ? (int) $svn[3] : date('Ymd');
    }
}
[/code]

__Tweak your view.yml__

[code yml]
    stylesheets:
    - style.css?&lt;?php echo sfSVN::getHeadRevision().PHP_EOL ?&gt;
  javascripts:
    - functions.js?&lt;?php echo sfSVN::getHeadRevision().PHP_EOL ?&gt;
    - set.js?&lt;?php echo sfSVN::getHeadRevision().PHP_EOL ?&gt;
[/code]

__Clear the cache__
[code]
$ symfony cc
[/code]

__The result__

[code html]
&lt;script type=&quot;text/javascript&quot; src=&quot;/js/functions.js?158&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;/js/set.js?158&quot;&gt;&lt;/script&gt;
&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; href=&quot;/css/style.css?158&quot; /&gt;
[/code]

__Notes__

This little script go read inside SVN file what's the last SVN revision number of your project __everytime you clear the cache__ so it doesn't add much i/o.

Help me to get this script better if you have any idea :)

Cheers,

[MA]Pascal</summary>
</entry>
<entry>
  <title>Créer un patch SVN et l'appliquer</title>
  <link href="http://snippets.prendreuncafe.com/snippet/87"></link>
  <updated>2008-04-11T09:23:03Z</updated>
  <id>87</id>
  <summary type="html">Pour mémoire, voici la méthode pour créer un patch depuis un dépôt subversion et l'appliquer sur un autre checkout de ce même dépôt :

[code]
$ cd /path/to/instance/1
$ svn diff /tmp/diff.patch
$ cd /path/to/instance/2
$ patch -p0 -i /tmp/diff.patch
[/code]</summary>
</entry>
<entry>
  <title>[Ubuntu] Intégrer Subversion dans Nautilus</title>
  <link href="http://snippets.prendreuncafe.com/snippet/50"></link>
  <updated>2007-01-30T15:51:46Z</updated>
  <id>50</id>
  <summary type="html">SVN dans Nautilus via un clic droit, c'est possible :
[code]
$ sudo apt-get install nautilus-script-collection-svn
$ nautilus-script-manager enable Subversion
[/code]

Merci glooze ;)</summary>
</entry>
<entry>
  <title>Ajouter automatiquement tous les nouveaux fichiers et dossiers dans un dépôt Subversion</title>
  <link href="http://snippets.prendreuncafe.com/snippet/49"></link>
  <updated>2007-01-30T15:46:18Z</updated>
  <id>49</id>
  <summary type="html">The command line is my friend.

[code]
$ svn stat | grep ? | awk '{ print $2 }' | xargs svn add
[/code]</summary>
</entry>
<entry>
  <title>Migrer un dépôt Subversion d'une machine à une autre</title>
  <link href="http://snippets.prendreuncafe.com/snippet/18"></link>
  <updated>2006-11-12T16:38:26Z</updated>
  <id>18</id>
  <summary type="html">Sur l'ancienne machine :

[code]
$ svnadmin dump /var/lib/subversion/myproject &gt; ~/myproject.svndump
$ scp ~/myproject.svndump new-server:
[/code]

Sur la nouvelle machine :

[code]
$ svnadmin create /var/lib/subversion/myproject
$ svnadmin load /var/lib/subversion/myproject &lt; ~/myproject.svndump
[/code]

Via http://fashion.hosmoz.net/blog/post/2006/11/09/Migrer-un-depot-subversion</summary>
</entry>
</feed>
