如何在 C# 中以编程方式获取 SVN 修订描述和作者?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/681770/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to programmatically get SVN revision description and author in c#?
提问by Tomasz Smykowski
How do I programmatically get the revision description and author from the SVN server in c#?
如何以编程方式从 c# 中的 SVN 服务器获取修订描述和作者?
采纳答案by Bert Huijben
Using SharpSvn:
使用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);
}
}
回答by Samuel
You will need to find a C# SVN API to use. A quick Google search found SharpSVN.
您需要找到一个 C# SVN API 才能使用。一个快速的谷歌搜索找到了SharpSVN。
To get message and author for specific revision
获取特定修订的消息和作者
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);
回答by Slipfish
I've done something similar to this a while back, we needed notification of certain repository commits.
不久前我做过类似的事情,我们需要某些存储库提交的通知。
I ended up using SubversionNotifyto do this. You could take a look at the code there and see what you can use.
我最终使用SubversionNotify来做到这一点。你可以看看那里的代码,看看你可以使用什么。
I do believe SubversionNotify is grabbing output from svnlook. Svnlook has quite a few arguments that can get what you're looking for.
我相信 SubversionNotify 正在从 svnlook 获取输出。Svnlook 有很多参数可以得到你想要的东西。
If you know the revision number and repository:
如果您知道修订号和存储库:
svnlook info -r [rev#] /path/to/repo
Will net you the User, Timestamp, Log message length, and the log message itself:
将为您提供用户、时间戳、日志消息长度和日志消息本身:
bob 2009-03-25 11:10:49 -0600 (Wed, 25 Mar 2009) 19 Did stuff with things.