Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using bash to get revision number from subversion

Tags:

bash

shell

I want to write a shell script in bash to deploy websites from an svn repository. When I deploy a website, I name the exported directory website_name-Rrevision_number. I'd like the bash script to automatically rename the exported directory, so it needs to learn the current revision number from the export directory. If I run

$> svn info http://svn-repository/trunk

Path: trunk
URL: http://svn-repository/mystery/trunk
Repository Root: http://svn-repository/mystery
Repository UUID: b809e6ab-5153-0410-a985-ac99030dffe6
Revision: 624
Node Kind: directory
Last Changed Author: author
Last Changed Rev: 624
Last Changed Date: 2010-02-19 15:48:16 -0500 (Fri, 19 Feb 2010)

The number after the string Revision: is what I want. How do I get that into a bash variable? Do I do string parsing of the output from the svn info command?

like image 783
user151841 Avatar asked Feb 19 '10 21:02

user151841


People also ask

How do I find my svn revision number?

To find information about the history of a file or directory, use the svn log command. svn log will provide you with a record of who made changes to a file or directory, at what revision it changed, the time and date of that revision, and, if it was provided, the log message that accompanied the commit.

How do I find a particular revision in svn?

If you want to write a script which requires no input, you should use the official Subversion command line client instead. checkout a working copy in REV revision: svn checkout --revision REV https://svn.example.com/svn/MyRepo/trunk/ svn checkout https://svn.example.com/svn/MyRepo/trunk/@REV.

What is Subversion revision number?

As you saw in the section called “Revisions”, revision numbers in Subversion are pretty straightforward—integers that keep getting larger as you commit more changes to your versioned data.

How can I get previous revision from svn?

Using the latest versions of Subclipse, you can actually view them without using the cmd prompt. On the file, simply right-click => Team => Switch to another branch/tag/revision.


2 Answers

Use svnversion. This will output the revision number/range with minimal additional cruft

like image 52
oefe Avatar answered Nov 11 '22 04:11

oefe


REVISION=`svn info http://svn-repository/trunk |grep '^Revision:' | sed -e 's/^Revision: //'`

It's simple, if inelegant.

like image 29
Paul Tomblin Avatar answered Nov 11 '22 04:11

Paul Tomblin