Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you determine the latest SVN revision number rooted in a directory?

I would like to start tagging my deployed binaries with the latest SVN revision number.

However, because SVN is file-based and not directory/project-based, I need to scan through all the directory's and subdirectory's files in order to determine the highest revision number.

Using svn info on the root doesn't work (it just reports the version of that directory, not files in subdirectories):

I was wondering if there is a shortcut using the svn command to do this. Otherwise, can anyone suggest a simple script that is network-efficient (I would prefer if it didn't hit the remote server at all)?

I also understand that one alternative approach is to keep a version file with the svn:keywords. This works (I've used it on other projects), but I get tired of dealing with making sure the file is dirty and dealing with the inevitable merge conflicts.

Answer I see my problem lied with not doing a proper svn up before calling svn info in the root directory:

$ svn info Path: . ... Last Changed Author: fak Last Changed Rev: 713 Last Changed Date: 2008-08-29 00:40:53 +0300 (Fri, 29 Aug 2008)  $ svn up At revision 721.  $ svn info Path: . ... Revision: 721 Last Changed Author: reuben Last Changed Rev: 721 Last Changed Date: 2008-08-31 22:55:22 +0300 (Sun, 31 Aug 2008) 
like image 591
Frank Krueger Avatar asked Sep 11 '08 10:09

Frank Krueger


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 get latest revision in svn?

"svn info --show-item revision" will give the current revision to which the current directory is updated.

What is revision number in svn?

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 do I find my svn revision number in Jenkins?

1 Answer. "http://your-jenkins-host/env-vars.html/" and you'd find a constant called "SVN_REVISION" Each job build will keep the SVN revision in the given variable.


Video Answer


1 Answers

One way. When you check out the code, look at the last line of svn output:

$ svn up ...stuff... Updated to revision 66593. 

A more direct way:

$ svn info Path: . URL: https://svn.example.com/svn/myproject/trunk Repository Root: https://svn.example.com/svn/ Repository UUID: d2a7a951-c712-0410-832a-9abccabd3052 Revision: 66593 Node Kind: directory Schedule: normal Last Changed Author: bnguyen Last Changed Rev: 66591 Last Changed Date: 2008-09-11 18:25:27 +1000 (Thu, 11 Sep 2008) 
like image 124
Charles Miller Avatar answered Oct 03 '22 19:10

Charles Miller