Export SVN Changes to zip file
June 5th, 2010
A co-worker of mine commented that Tortoise has an easy way to export out the diff between two revisions and wondered if there was an easy way to do this on his mac. I replied “well you could write a script to parse an svn diff”. So here it is, ready for you to snag from github.
http://github.com/zerium/export_svn_changes
Instructions attached below from the README in github.
This file is designed to export the files that were modified or added between two svn revisions. It will output a corresponding zip file with the directory structure intact. Useful for when you need to push code but the server you are pushing to doesn’t have access to your repository.
Recomendations
It is reccomended that you set this to executable and add it to your path in your .profile (otherwise you will have to copy it to each repo)
Requirements
OSX is not required but, it is a requirement that “svn” and “zip” are installed in the OS.
Example:
cd [/repo_root]
export_changes.rb 1550:1560
Produces: 1550_1560.zip
August 9th, 2010 at 01:18 PM
Hi Steven,
thank you very much for sharing this very useful script. That’s just what I was looking for. It seems that currently not one of all the graphical SVN-clients for the Mac support this kind of feature – which I cannot understand. It is so essential if you are a developing a PHP based website – where it is total overkill to export & upload the whole repository each time you have made some small changes.
Do you think it would be possible to create an automator action, that I could start by right-clicking the SVN-project-folder in the finder and it will put up an dialogue box for letting me enter the input parameter?
Thanks again and best regards, Lorenz
September 18th, 2010 at 02:47 AM
It appears that this is less of an issue with Git than SVN. Git only puts a .git folder in the repository root, whereas SVN puts a .svn folder in every subdirectory. So “svn export” avoids recursive command-line magic, whereas with Git recursion is not necessary.
October 15th, 2010 at 07:06 AM
Lorenz – I guess I could do that but, I’ll leave it up to the reader! I have the terminal open all day so I really don’t find it to be an issue however, if you want an easier method you can always drag the directory that you want to run the command in (from the finder) to the terminal so you can cd to it and then run the ruby file.
November 4th, 2010 at 04:39 AM
Hey Steve,
thanks for the hint. I didn’t know about that ‘drag to terminal’-capability. I like my Mac more and more each day… I’m also really comfortable with your script by now. It really helps me a lot. So thanks for that!
But still I’m considering using Platypus which serves as an application wrapper for scripts. Looks pretty interesting – so I might give it a try when I find the time.
November 18th, 2010 at 11:13 AM
Smithson – too true, loving git more and more each day. Just moved the main project I am working on these days into it and already seeing why everyone raves about it.
January 29th, 2011 at 03:55 AM
Great script that solves a glaring issue SVN should support natively.
I forked it on GitHub and made one minor change to it: after a few too many accidental commits of the generated .zip to SVN (since it was being saved to the docroot of the project), I modified it to save the .zip to the user’s Desktop instead.
Thanks!