Skip to content

Instantly share code, notes, and snippets.

@koenrh
Last active December 17, 2015 20:19
Show Gist options
  • Save koenrh/5666575 to your computer and use it in GitHub Desktop.
Save koenrh/5666575 to your computer and use it in GitHub Desktop.
While working on continuous integration, I needed the name of the most recently created tag in a Subversion repository. So I wrote a little PowerShell script that would find the name for me by looking in the Subversion log.
Param(
[string]$Url = "svn://my.repo.url",
[string]$Username = "krouwhorst",
[string]$Password = "secret"
)
Function Get-SubversionLog {
([xml](svn log $Url --xml --verbose --username $Username --password $Password)).log.logentry | ForEach {
$item = $_
$_.paths.path | ForEach {
$path = $_
$item | Select -Property @(
@{ Name='Author'; Expression={$_.Author}},
@{ Name='Revision'; Expression={([int]$_.Revision)}},
@{ Name='Message'; Expression={$_.msg}},
@{ Name='Date'; Expression={Get-Date $_.Date}},
@{ Name='Action'; Expression={$path.action}},
@{ Name='Kind'; Expression={$path.kind}},
@{ Name='Path'; Expression={$path.InnerText}})
}
}
}
Get-SubversionLog |
Where { $_.Action -eq 'A' -and $_.Kind -eq 'dir' -and $_.Path -like '*/tags/*' } |
Select Author, Revision, Date, Path |
Sort Date -Descending |
Select -First 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment