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

前端 未结 3 648
隐瞒了意图╮
隐瞒了意图╮ 2021-02-02 00:42

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

相关标签:
3条回答
  • 2021-02-02 01:24

    I've done something similar to this a while back, we needed notification of certain repository commits.

    I ended up using SubversionNotify to do this. You could take a look at the code there and see what you can use.

    I do believe SubversionNotify is grabbing output from svnlook. Svnlook has quite a few arguments that can get what you're looking for.

    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.
    
    0 讨论(0)
  • 2021-02-02 01:27

    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);
    
    0 讨论(0)
  • 2021-02-02 01:29

    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);
        }
    }
    
    0 讨论(0)
提交回复
热议问题