PowerShell, Subversion One Liner

August 26, 2007

in PowerShell,Subversion

([xml](svn info C:\Code --xml)).info.entry.revision

Returns the revision number of a subversion working copy.

Wrap it in a function

function Get-SvnRevision($dir)
{
([xml](svn info $dir --xml)).info.entry.revision
}

Get-SvnRevision C:\Code

This comes in handy when building scripts to interact with Subversion.

Automating an svn update, compiling the code and producing executables with the svn revision number burned in for QA and Customer tracking.

{ 3 comments… read them below or add one }

Grant Steinfeld 03.05.08 at 9:26 am

and of course another one of your great one liners :)

$log = [xml] (svn log http://svn.smartorg.com/svn/dev/SpikeTests –xml); $log.log.logentry | ft author, msg -auto | more

Richard Howells 07.21.12 at 6:46 am

Hi Doug,

The function version has only one ‘-’ before the xml.

I could not get the PowerShell function version to work until I modified -xml to –xml. I’m a PowerShell noob. Did I miss somthing?

Thanks.

Doug Finke 07.22.12 at 8:33 am

Thanks for the comment Richard. You are correct.
The HTML had the –xml. I wrapped it in a pre tag and now it shows up in the post.

Thanks for catching that.

Doug

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Contrat Creative Commons

© 2007-2013, Doug Finke