Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to programmatically get SVN revision description and author in c#?

Tags:

c#

svn

How do I programmatically get the revision description and author from the SVN server in c#?

like image 796
Tom Smykowski Avatar asked Mar 25 '09 14:03

Tom Smykowski


People also ask

How do I find my svn revision history?

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.

How do I find my svn revision number?

"svn info --show-item revision" will give the current revision to which the current directory is updated.

How do I checkout revision in svn?

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.


2 Answers

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);
    }
}
like image 56
Bert Huijben Avatar answered Oct 10 '22 02:10

Bert Huijben


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);
like image 33
Samuel Avatar answered Oct 10 '22 00:10

Samuel