Subversion Repositories DevTools

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

<#
.SYNOPSIS
This Powershell script will update the repo-Wide hook in all the Repos
 
.DESCRIPTION
        This Powershell script update the repo-Wide hook in all the Repos on
    the current machine.

        It will
                Locate the Repositoties Root
        Copy *.cmd file from the root into each Repo Subdir
            Unless the special hooks/specialhooks file exists

.EXAMPLE
UpdateHooks.ps1
 
.NOTES
Uses a number of cmdlets provided by VisualSVN.
 
#>
#

#
#   Get information on a named repo
function GetRepoInfo( $repoName )
{
    $repoData = Get-CimInstance -Namespace "root\VisualSVN" -ClassName VisualSVN_Repository | Where { $_.Name -eq $repoName } 
    Return $RepoData
}

#
#   Get information on the current SVN server
#
function GetSvnInfo()
{
    $repoData = Get-CimInstance -Namespace "root\VisualSVN" -ClassName VisualSVN_Service
    Return $RepoData
}

#
# Determine the root of the Repositores
$SvnInfo = GetSvnInfo
if ($SvnInfo -eq $null)
{
    Write-Error 'Cannot get VisualSVN info'
    Exit
}

# Validate the Repo Root
$repoRoot = $SvnInfo.RepositoriesRoot
If (!(Test-Path $repoRoot)) 
{
    Write-Error 'RepositoriesRoot - Does not exist'
    Exit
}

#
# Process each Repo
$HookSrc = $repoRoot
Get-CimInstance -Namespace "root\VisualSVN" -ClassName VisualSVN_Repository | Sort-Object Name | ForEach-Object {
    $hookPath = $_.Path  + '/hooks'
    $repoName = $_.Name

    If (!(Test-Path ($hookPath + '/specialhooks')))
    {

        $HookFileCount = 0

        Get-ChildItem $HookSrc -Filter '*.cmd' | ForEach-Object {
            $srcFile = $_.Name
            Copy-Item $_.FullName -Destination $hookPath 
            $HookFileCount++
        }
        Write-Host ("{0,20} : {1}" -f $repoName, "Hooks copied: $HookFileCount")
    }
    else
    {
        Write-Host ("{0,20} : {1}" -f $repoName, "SPECIAL - No hooks copied")
    }

}