Get revision number of a remote repository

别等时光非礼了梦想. 提交于 2019-12-21 04:04:42

问题


On the local machine it is no problem to get the revision number of a subversion repository with svnversion. Now I want to get the revision number from my online repository (WebDAV with Apache2).

I tried this:

svnversion http://nick:password@www.myhost.de/svn/test`

In a browser it worked as usual (just to ensure there weren't typos or so), but svnversion said that the directory cannot be found. So I presume I was on the wrong track.

How can I get the revision number?


回答1:


svnversion is just for working copies, but one way to query your repository would be to use svn info as follows:

svn info http://nick:password@www.myhost.de/svn | grep Revision



回答2:


On Linux, if you want just the revision number:

svn info http://nick:password@www.myhost.de/svn/test | grep '^Revision:' | awk '{print $2}'




回答3:


svn info http://nick:password@www.myhost.de/svn/test

should return information about the remote repository, including Revision




回答4:


A handy AWK one-liner to get only the number portion:

svn info http://nick:password@www.myhost.de/svn | awk '/Revision:/ { print $2 }'



回答5:


On new version of svn (1.9) you can do:

svn info --show-item revision svn://...
18436 

This should return only the revision number.

All the grep version will break if your locale is not english.

For previous version, you can try

svn info --xml | grep '<entry' -3 | awk -F '=' '/revision="/ { print $2 }' | grep -o '[0-9]\+'

If you can have the xml2 package a better way is to do:

svn info --xml | xml2 | grep /info/entry/@revision | grep -o '[0-9]\+' 


来源:https://stackoverflow.com/questions/623378/get-revision-number-of-a-remote-repository

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!