andy
andy

Reputation: 8881

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.

Upvotes: 3

Views: 1332

Answers (1)

John Rasch
John Rasch

Reputation: 63505

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();
    }
}

Upvotes: 6

Related Questions