Subversion Repositories DevTools

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5287 dpurdie 1
<#
2
.SYNOPSIS
3
This Powershell script will update the repo-Wide hook in all the Repos
4
 
5
.DESCRIPTION
6
	This Powershell script update the repo-Wide hook in all the Repos on
7
    the current machine.
8
 
9
	It will
10
		Locate the Repositoties Root
11
        Copy *.cmd file from the root into each Repo Subdir
12
            Unless the special hooks/specialhooks file exists
13
 
14
.EXAMPLE
15
UpdateHooks.ps1
16
 
17
.NOTES
18
Uses a number of cmdlets provided by VisualSVN.
19
 
20
#>
21
#
22
 
23
#
24
#   Get information on a named repo
25
function GetRepoInfo( $repoName )
26
{
27
    $repoData = Get-CimInstance -Namespace "root\VisualSVN" -ClassName VisualSVN_Repository | Where { $_.Name -eq $repoName } 
28
    Return $RepoData
29
}
30
 
31
#
32
#   Get information on the current SVN server
33
#
34
function GetSvnInfo()
35
{
36
    $repoData = Get-CimInstance -Namespace "root\VisualSVN" -ClassName VisualSVN_Service
37
    Return $RepoData
38
}
39
 
40
#
41
# Determine the root of the Repositores
42
$SvnInfo = GetSvnInfo
43
if ($SvnInfo -eq $null)
44
{
45
    Write-Error 'Cannot get VisualSVN info'
46
    Exit
47
}
48
 
49
# Validate the Repo Root
50
$repoRoot = $SvnInfo.RepositoriesRoot
51
If (!(Test-Path $repoRoot)) 
52
{
53
    Write-Error 'RepositoriesRoot - Does not exist'
54
    Exit
55
}
56
 
57
#
58
# Process each Repo
59
$HookSrc = $repoRoot
60
Get-CimInstance -Namespace "root\VisualSVN" -ClassName VisualSVN_Repository | Sort-Object Name | ForEach-Object {
61
    $hookPath = $_.Path  + '/hooks'
62
    $repoName = $_.Name
63
 
64
    If (!(Test-Path ($hookPath + '/specialhooks')))
65
    {
66
 
67
        $HookFileCount = 0
68
 
69
        Get-ChildItem $HookSrc -Filter '*.cmd' | ForEach-Object {
70
            $srcFile = $_.Name
71
            Copy-Item $_.FullName -Destination $hookPath 
72
            $HookFileCount++
73
        }
74
        Write-Host ("{0,20} : {1}" -f $repoName, "Hooks copied: $HookFileCount")
75
    }
76
    else
77
    {
78
        Write-Host ("{0,20} : {1}" -f $repoName, "SPECIAL - No hooks copied")
79
    }
80
 
81
}
82