Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the HEAD revision number of a given repository using svn?

Tags:

svn

I want to create a Qt app which, among other things, will display the current revision number (that is the HEAD revision number) of a particular repository URL. With the help of svn help and this and this link, I was able to almost get what I want by calling the command svn info <repository-url>. The problem is that this command return lots of unwanted info (such as "last changed author", etc.), while I want only the revision number (or as much as few text as possible).

So how can I do it?

like image 351
Momergil Avatar asked Jan 09 '23 14:01

Momergil


2 Answers

As per comments, to get the HEAD revision number of a given repository using svn:

svn info <repository-url> -r 'HEAD' | grep Revision | egrep -o "[0-9]+"
like image 164
Ivan Jovović Avatar answered May 11 '23 10:05

Ivan Jovović


Since you write "of a particular repository URL", is your aim to get the revision number of the last change of that specific URL (e.g. of a branch)? If so, sou might be interested in Last Changed Rev instead of Revision.

The Revision refers to the root repository, so it might not be what you want if you use the URL of a branch: the returned Revision field is the same regardless the branch specified in the URL.

In any case, as @vijucat mentioned in a comment, a cleaner way to retrieve the revision is to add --show-item, which supports either revision or last-changed-revision.

like image 34
Narcolessico Avatar answered May 11 '23 08:05

Narcolessico