Sam
Sam

Reputation: 894

Perform SVN operations through a ruby script on windows/osx

I am a newbie and need to perform some basic SVN operations (like get info of the repository, add, commit, update etc) through a ruby script, on both windows/osx.

I searched the forum and internet, only to find partial and confusing answers related to SWIG ruby-subversion bindings etc, but none of them was well documented or simple enough to use [Also, most of these questions and answers are pretty old].

I am assuming that a simpler way to perform SVN operations through a ruby script should exist by now. Correct me if my assumption is wrong.

Also, is it worth the hassle to install SWIG bindings, understand 'svn/core' library and use it with a gem (like svn_wc) OR better to simply call svn command line commands from ruby? Is there a massive difference in performance for these approaches?

Any help will be much appreciated.

Upvotes: 1

Views: 470

Answers (1)

Toni
Toni

Reputation: 11

A simple way is to use SVN command line tools from Ruby. Say you are in a sandbox and you have a script 'svn-get_uuid'. It could look like this:

$ cat svn-get_uuid
#!/usr/bin/ruby
uuid = `svn info`.lines.grep /^UUID/
uuid =  uuid[0].chomp.sub /^.*: (.+)/, '\1'
print "{#{uuid}}\n"

$ ./svn-get_uuid
{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}

May be you can do it faster using the svn-bindings, but working this way is OK for my daily work.

Upvotes: 1

Related Questions