如何以编程方式在c#中从SVN服务器获取修订说明和作者?
使用 SharpSvn:
using(SvnClient client = new SvnClient())
{
Collection<SvnLogEventArgs> list;
// When not using cached credentials
// c.Authentication.DefaultCredentials = new NetworkCredential("user", "pass")l
SvnLogArgs la = new SvnLogArgs { Start = 128, End = 132 };
client.GetLog(new Uri("http://my/repository"), la, out list);
foreach(SvnLogEventArgs a in list)
{
Console.WriteLine("=== r{0} : {1} ====", a.Revision, a.Author);
Console.WriteLine(a.LogMessage);
}
}
您需要找到一个C# SVN API来使用。快速的谷歌搜索发现了SharpSVN。
获取特定版本的消息和作者信息:
SvnClient client = new SvnClient();
SvnUriTarget uri = new SvnUriTarget("url", REV_NUM);
string message, author;
client.GetRevisionProperty(uri, "svn:log", out message);
client.GetRevisionProperty(uri, "svn:author", out author);
我以前做过类似的事情,我们需要通知某些仓库提交。
最终我使用了SubversionNotify来完成此任务。你可以查看那里的代码并看看你可以使用什么。
我相信SubversionNotify正在从svnlook获取输出。Svnlook有很多参数可以获得你要查找的内容。
如果你知道修订号和仓库:
svnlook info -r [rev#] /path/to/repo
将为您提供用户、时间戳、日志消息长度和日志消息本身:
bob 2009-03-25 11:10:49 -0600 (Wed, 25 Mar 2009) 19 Did stuff with things.