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

前端 未结 10 1676
北恋
北恋 2020-12-02 15:45

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

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 16:15

    If you just want the revision number of the latest change that was committed, and are using Windows without grep/awk/xargs, here is the bare-bones command to run (command line):

    X:\trunk>svn info -r COMMITTED | for /F "tokens=2" %r in ('findstr /R "^Revision"') DO @echo %r
    67000
    

    svn info -r COMMITTED will give you the latest committed change to the directory you are currently in:

    X:\Trunk>svn info -r COMMITTED
    Path: trunk
    URL: https://svn.example.com/svn/myproject/trunk
    Repository Root: https://svn.example.com/svn/
    Repository UUID: d2a7a951-c712-0410-832a-9abccabd3052
    Revision: 67400
    Node Kind: directory
    Last Changed Author: example
    Last Changed Rev: 67400
    Last Changed Date: 2008-09-11 18:25:27 +1000 (Thu, 11 Sep 2008)
    

    The for loop runs findstr to locate the Revision portion of the output from svn info. The output from this will be (you won't see this):

    Revision: 67000
    

    Which then splits the tokens, and returns the 2nd, to be echoed out:

    67000
    

提交回复
热议问题