Skip to main content.
May 27th, 2008

svn get revision

One of the more annoying things about svn is that (to my knowledge), there exists no single simple command to retrieve the revision number from a shell.

What I want:

ammon@hermes:~/repo$ svn info --get-revision .
1234

But of course, nothing like this exists.

Thankfully, svn info's output IS easy enough to parse. You just have to do it your self.

ammon@hermes:~/repo$ svn info | grep Revision | awk -- '{print $2}'
1234

Will give you the revision of your current checkout without the network hit of a call to svn log.

To get the current version of the repo itself (hits the network), add "-r HEAD" to the svn info call:

ammon@hermes:~/repo$ svn info -r HEAD | grep Revision | awk -- '{print $2}'
1280

Of course, svn info also supports outputting info as xml, so you could use that to parse things in a more advanced environment but one where you're still not using the svn api bindings.

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • Technorati
  • Reddit

Posted by Ammon in play

This entry was posted on Tuesday, May 27th, 2008 at 12:57 pm and is filed under play. You can follow any responses to this entry through the comments RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>