How do I programmatically get the revision description and author from the SVN server in c#?
To find information about the history of a file or directory, use the svn log command. svn log will provide you with a record of who made changes to a file or directory, at what revision it changed, the time and date of that revision, and, if it was provided, the log message that accompanied the commit.
"svn info --show-item revision" will give the current revision to which the current directory is updated.
If you want to write a script which requires no input, you should use the official Subversion command line client instead. checkout a working copy in REV revision: svn checkout --revision REV https://svn.example.com/svn/MyRepo/trunk/ svn checkout https://svn.example.com/svn/MyRepo/trunk/@REV.
Using 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);
}
}
You will need to find a C# SVN API to use. A quick Google search found 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);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With