如何使用SharpSVN访问SVN预提交消息?
问题描述:
我看到我只能设置为%repos%和%txn%
i see that all I can set to is %repos% and %txn%
我该如何使用它们来获取提交消息(以我为例,因此我可以解析票证编号,以便可以在提交之前查看错误数据库中是否存在该票证编号)
how can I use those to get to the commit message (in my case, so i can parse out the ticket number so i can see if it exists in the bug database before committing to it)
答
使用最新的 SharpSvn 版本可以使用
Using a recent SharpSvn release you can use
SvnHookArguments ha;
if (!SvnHookArguments.ParseHookArguments(args, SvnHookType.PreCommit, false, out ha))
{
Console.Error.WriteLine("Invalid arguments");
Environment.Exit(1);
}
解析预提交钩子的参数,然后使用
to parse the arguments of a pre-commit hook and then use
using (SvnLookClient cl = new SvnLookClient())
{
SvnChangeInfoEventArgs ci;
cl.GetChangeInfo(ha.LookOrigin, out ci);
// ci contains information on the commit e.g.
Console.WriteLine(ci.LogMessage); // Has log message
foreach (SvnChangeItem i in ci.ChangedPaths)
{
}
}
获取日志消息,更改的文件等.
to get to the log message, changed files, etc.