Is there some svn
or svnadmin
command that will display the revision of a local repo? I'd like to be able to have 开发者_开发知识库a Windows batch or PowerShell script that would let me zip up the repo and name it with the rev to email.
The best I can figure out is just to find the highest file in [reporoot]\db\revs\0
, but it seems kind of clunky and I don't know if it is reliable.
function Get-SvnRevision($dir)
{
([xml](svn info $dir --xml)).info.entry.revision
}
PowerShell, Subversion One Liner
(Edit) svnversion
is not so good because it relates to the working copy, not to the repository.
svn info
also relates to the working copy.
=> svnlook youngest REPOS_PATH
should do it. See also svn redbook.
svnversion is the command you want. Run svnversion --help
for an explanation of the output.
You can also use svn info
which has the advantage that you don't need to run it somewhere inside the working copy (or provide a path to a working copy) -- you can pass it a URL to the repo and it displays various information about the repository including the latest revision number. svnversion
in contrast would show the last revision number of the working copy, but this doesn't need to be identical to the revision of the repository.
Furthermore, svn info
shows more details about the repository than svnversion
. This might be a pro or a con, depending on your use.
Try the VisualSVN Powershell Commands:
Get-Command -Module VisualSVN
Get-SvnRepository will give you a list of repositories and the Revision numbers. The reference is at https://www.visualsvn.com/support/topic/00088/
The previous responses might not work with all versions of subversion, not sure if the older versions of subversion support xml parsed output. Can substitute "Revision" for another info property.
#this do an info split by new line split by : then get the second parameter where first parameter is equal to Revision
$svnRevision = (svn info "somedirectoryorurl" ) | %{$_ -split '#'} | Where-Object {($_ -split ":")[0] -eq "Revision"} | %{($_ -split ":")[1].Trim()}
精彩评论