How do I use a start commit hook in TortoiseSVN to setup a custom log entry?

喜欢而已 提交于 2019-12-08 03:51:34

问题


I'd like to automate TortoiseSVN as part of a commit process. Specifically I'd like to dynamically create a log entry for the commit dialog.

I know that I can launch the commit dialog either from the commandline or by right clicking on a folder and selecting svncommit.

I'd like to use the start commit hook to setup a log entry. I thought this worked by passing an entry file name in the MESSAGEFILE variable but when I add a hook script it cannot see this variable (hook launched successfully after right clicking and choosing svncommit).

When I try using the commandline I use the /logmsgfile parameter but it seems to have no effect.

I'm using tortoisesvn 1.5.3.


回答1:


Looks like it was my own misunderstanding of the the API that caused by a problem.

Solution:
1) I've added a start commit hook script to TortoiseSVN using the hooks gui in the settings area of the right click menu.

2) The script receive 3 pieces of information: PATH MESSAGEFILE CWD
For details see: Manual
These are passed as command line arguements to the script - for some reason I had thought they were set as temporary environmental variables.

My script then simply opens the file specified by the second arguement and adds in the custom text.

When the commit dialog comes up the custom text is there.

3) Best of all if tortoisesvn is launched from a script directly into the commit dialog:
e.g. [ tortoiseproc /command:commit /path:. /closeonend:1 ]
The hooks are still called.




回答2:


If you just need a static template, set the tsvn:logtemplate property.

For dynamic generation, the /logmsgfile parameter does work, but it seems to need the full path. A batch file that looks like the following might work for you.

GenerateLogMsg.exe > tmp.msg
"C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe" /command:commit /path:. /logmsgfile:"C:\Documents and Settings\User\My Documents\Visual Studio Projects\Project\tmp.msg"


来源:https://stackoverflow.com/questions/59007/how-do-i-use-a-start-commit-hook-in-tortoisesvn-to-setup-a-custom-log-entry

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!