If you want to abort a commit if your code fails certain rule and you don’t have access to the SVN Server to configure a hook. What do you do ?
Here is an example – Say you want to abort commit if you have a comment in your code that starts with //Do Not Commit. You can create a PowerShell script that validates all the files in your changeset and use this script as a Client-Side pre_commit_hook in TortoiseSVN.
The pre_commit_hook configuration :
//Powershell script : pre_commit.ps1
$donotcommit = “//Do Not Commit“;
$changeset = Get-Content $args;
foreach($file in $changeset)
if( Get-Content $file | Select-String $donotcommit -quiet )
Write-Error “$file contains code that you are not supposed to commit. [$donotcommit]“;
Now, if your changeset has a file with a comment starting with //Do Not Commit and you click on OK to commit this change, the commit will be aborted with this error message -