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?
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]+"
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
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With