SharpSVN得到的post-commit钩与 'SvnLookClient'
-
12-09-2019 - |
题
我想弄清楚如何获得一个特定版本的提交信息。它看起来像SvnLookClient可能是我所需要的。
我发现了一些代码在这里上,这样看起来像什么,我需要,但我似乎失去了一些东西..
码I实测值(在这里如此):
using (SvnLookClient cl = new SvnLookClient())
{
SvnChangeInfoEventArgs ci;
//******what is lookorigin? do I pass the revision here??
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)
{
}
}
解决方案
在客户svnlook的具体针对性用于使用在存储库钩。它允许访问未提交的修改,因此需要其他参数。 (这是SharpSvn相当于使用“svnlook”的命令。如果你需要一个“SVN”相当于你应该看看SvnClient)。
一个外表来源可以是: * A库路径和事务名 *或存储库路径和修订号
E.g。在pre-commit钩子的修订尚未提交,所以你不能访问它在公共URL,就像你通常会做。
文档说(在预commit.tmpl):
# The pre-commit hook is invoked before a Subversion txn is
# committed. Subversion runs this hook by invoking a program
# (script, executable, binary, etc.) named 'pre-commit' (for which
# this file is a template), with the following ordered arguments:
#
# [1] REPOS-PATH (the path to this repository)
# [2] TXN-NAME (the name of the txn about to be committed)
SharpSvn通过提供可帮助您:
SvnHookArguments ha;
if (!SvnHookArguments.ParseHookArguments(args, SvnHookType.PostCommit, false, out ha))
{
Console.Error.WriteLine("Invalid arguments");
Environment.Exit(1);
}
,它解析这些参数为您服务。 (在这种情况下是很简单的,但也有更先进的挂钩。而挂钩可以更新的Subversion版本接收新的参数)。所需的值是在公顷的.LookOrigin属性。
如果你只是想有一个特定的修订范围的事件日志消息(1234-4567),你不应该看SvnLookClient。
using(SvnClient cl = new SvnClient())
{
SvnLogArgs la = new SvnLogArgs();
Collection<SvnLogEventArgs> col;
la.Start = 1234;
la.End = 4567;
cl.GetLog(new Uri("http://svn.collab.net/repos/svn"), la, out col))
}
其他提示
仅供参考,我由基于Bert的响应一个C#函数。感谢伯特!
public static string GetLogMessage(string uri, int revision)
{
string message = null;
using (SvnClient cl = new SvnClient())
{
SvnLogArgs la = new SvnLogArgs();
Collection<SvnLogEventArgs> col;
la.Start = revision;
la.End = revision;
bool gotLog = cl.GetLog(new Uri(uri), la, out col);
if (gotLog)
{
message = col[0].LogMessage;
}
}
return message;
}
没有呀,我觉得我有这个代码,我将在后面张贴。 SharpSVN具有可以说是(IMHO)混淆API。
我想你想.LOG(SvnClient的),或类似的,传递你以后的修订工作。
不隶属于 StackOverflow