Skip to content

Commit 94d563a

Browse files
DavidHopkinsFbrdregad
authored andcommitted
SVN: add Windows hook examples
Fixes #311
1 parent d4dd2a8 commit 94d563a

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

SourceSVN/post-commit.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
REM Command line wrapper to start PowerShell hook script
2+
@echo off
3+
set PWSH=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe
4+
%PWSH% -ExecutionPolicy Bypass -NonInteractive -NoProfile -Command "$input | %1\hooks\post-commit.ps1" "%1" "%2" "%3"
5+
if errorlevel 1 exit /b %errorlevel%

SourceSVN/post-commit.ps1

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
param( $reposPath, $rev, $txnName )
2+
3+
# Update MantisBT integration with detail of updated log message
4+
# Replace all "<CONFIGURATION_CONSTANTS>" with the appropriate values
5+
$url='https://<YOUR_MANTIS_HOST_HERE>/mantisbt/plugin.php?page=Source/checkin'
6+
$repoName='<MANTISBT_SOURCESVN_REPOSITORY_NAME>'
7+
$apiKey='<MANTISBT_SOURCE_INTEGRATION_APIKEY_VALUE>'
8+
9+
$logFile="$(env:temp)\svn_post-commit_$($repoName)_$($rev).log"
10+
11+
# Assemble HTTP request body
12+
$body= @{
13+
repo_name=$repoName
14+
data=$rev
15+
api_key=$apiKey
16+
}
17+
18+
Invoke-WebRequest -Uri $url -Body $body -Method 'POST' -OutFile $logFile

SourceSVN/post-revprop-change.bat

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
REM Command line wrapper to start PowerShell hook script
2+
@echo off
3+
set PWSH=%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe
4+
%PWSH% -ExecutionPolicy Bypass -NonInteractive -NoProfile -Command "$input | %1\hooks\post-revprop-change.ps1" "%1" "%2" "%3" "%4" "%5"
5+
if errorlevel 1 exit /b %errorlevel%

SourceSVN/post-revprop-change.ps1

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
param( $reposPath, $rev, $user, $propName, $action )
2+
3+
# Replace all "<CONFIGURATION_CONSTANTS>" with the appropriate values
4+
$url='https://<YOUR_MANTIS_HOST_HERE>/mantisbt/plugin.php?page=Source/checkin'
5+
$repoName='<MANTISBT_SOURCESVN_REPOSITORY_NAME>'
6+
$apiKey='<MANTISBT_SOURCE_INTEGRATION_APIKEY_VALUE>'
7+
8+
if ( $propName -eq 'svn:log' )
9+
{
10+
$logFile="$(env:temp)\svn_post-revprop-change_$($repoName)_$($rev).log"
11+
12+
# Assemble HTTP request body
13+
$body = @{
14+
repo_name=$repoName
15+
data=$rev
16+
revprop='TRUE'
17+
api_key=$apiKey
18+
}
19+
20+
# Update MantisBT integration with detail of updated log message
21+
Invoke-WebRequest -Uri $url -Body $body -Method 'POST' -OutFile $logFile
22+
}

0 commit comments

Comments
 (0)