squeekjjy
Hi, What OS are you using? The reason I ask is I think there might be a way to implant the svnlook changed command into your script. The idea is that we get it to only look at one project, if anything has been changed in that project then the pre-commit hook works, if there isn't any changes to that project then the pre-commit hook just closes down.
andyl
Parse the output of svnlook changed, test the paths, and only fire your logic for that specific branch.
squeekjjy
Hi Andyl, Do you think the idea I had would work using svnlook changed or maybe you have an idea on how to do this?
deepak8373
how can we get the branch name in the precommit hook . So that i can keep condition of this particular branch .
squeekjjy
Deepak8373, the best thing to do would ask andyl if he is able to help, but as he said, he is a little busy so you may have to wait a little bit. He is the best person to help you out with this and tbh, you are in very good hands.
andyl
Oh how I loathe Windows sometimes. Especially when having to cross the BAT/PoSH barrier in this context. This is not working, but I've spent far too much time on it thus far. pre-commit.bat:@echo off C:\Windows\System32\WindowsPowershell\v1.0\powershell.exe -file C:\_data\Repositories\Test\hooks\pre-commit.ps1 -repos_path "%1" -txn %2 1>&2 exit %ERRORLEVEL%
pre-commit.ps1:#requires -version 2.0 [cmdletBinding()] param( [Parameter(Mandatory=$true)] [ValidateScript({Test-Path $_})] [alias("Repository","Repo")] [string]$repos_path, [Parameter(Mandatory=$true)] [alias("transaction")] [string]$txn ) $svnProg = $changedPaths = & 'C:\Program Files\TortoiseSVN\bin\svnlook.exe' changed $repos_path -t $txn; # Branch/Project2 $runFullPreCommit = $false; foreach ($path in $changedPaths) { if ($path.Contains("Project/Branch2")) { $runFullPreCommit = $true; } } if ($runFullPreCommit) { $logContent = & 'C:\Program Files\TortoiseSVN\bin\svnlook.exe' log $repos_path -t $txn; if (-not $logContent.StartsWith("Def")) { Write-Error "Your log message did not pass validation. It must start with `"Def`""; throw 'ERROR'; } }
But it's not working properly. Hopefully this is enough to get you moving forward.
srichary04
Nee a help on the below pre-commit requirement... trunk Branch1 When user wants to commit the code changes to the Branch1 before commit the same changes to the trunk. Restrict these commits when its not committed to trunk first and then Branch. Restrict the user commit in the below (2) scenarios: Scenario1: When adding new file to Branch1 and try to commit (file not committed to the trunk) Scenario2: Changes to the existing file and try to commit to the Branch1 (Changes not committed to the trunk). TIA.
DougR
It's pretty much the same as described above: use "svnlook" to find the paths in the branch. Then make sure that those paths exist on the trunk. And perhaps diff the trunk/branch files to see that they have at least something in common...