Skip to content

Instantly share code, notes, and snippets.

@drasive
Last active October 30, 2015 08:03
Show Gist options
  • Save drasive/70d60b0af6bdfc3e0a57 to your computer and use it in GitHub Desktop.
Save drasive/70d60b0af6bdfc3e0a57 to your computer and use it in GitHub Desktop.
$path = Split-Path -Parent -Path $MyInvocation.MyCommand.Definition
$maximumDirectoryDepth = 3
$excludedDirectories = @()
$directoryDepth = 0
$repositoriesUpdated = 0
function Get-IsSvnRepository($path) {
svn info $path > $null 2>&1
$?
}
function Update-Repositories($path) {
foreach ($directoryPath in Get-ChildItem $path | ?{ $_.PSIsContainer } | %{ $_.FullName } )
{
$directoryName = Split-Path (Split-Path $directoryPath -Parent) -Leaf
if ($excludedDirectories -contains $directoryName) {
continue
}
if (Get-IsSvnRepository($directoryPath)) {
Write-Host $directoryPath
svn update $directoryPath
Write-Host "`n"
$script:repositoriesUpdated++
}
elseif ($directoryDepth -lt $maximumDirectoryDepth) {
$script:directoryDepth++
Set-Location -Path $directoryPath
Update-Repositories(Get-Location)
$script:directoryDepth--
cd ..
}
}
}
Update-Repositories($path)
Write-Host "Updated $repositoriesUpdated repositories"
Write-Host "Press any key to continue ..."
$host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown") > $null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment