Search code examples
c#.netsvnloggingsharpsvn

How to programatically in c# get the latest top "n" commit messages from a svn repository


I'd like to build a site which simply displays the top latest (by date, revision?) "n" commit logs plus other associated info.

What's the best way to do this? I started having a quick look at SharpSvn, but the GET seems to be based on Revision ranges rather than date.

I'd like a simple example for .Net in c# based on any available library which gets the job done.


Solution

  • Since you mentioned using SharpSVN, I happen to have written this in BuildMaster:

    private static IList<string> GetLatestCommitMessages(Uri repository, int count)
    {
        using (var client = new SvnClient())
        {
            System.Collections.ObjectModel.Collection<SvnLogEventArgs> logEntries;
            var args = new SvnLogArgs()
            {
                Limit = count
            };
    
            client.GetLog(repository, args, out logEntries);
    
            return logEntries.Select(log => log.LogMessage).ToList();
        }
    }