0

我需要实现从 SVN 存储库中检索提交列表并将它们显示在网页上的应用程序。

我该怎么做 ?

我不太明白我应该使用什么。似乎可以使用一些 SVN api 或库来完成......

(.NET 中的应用程序)

4

2 回答 2

1

这是我用来从 .NET 环境执行 SVN 命令的漂亮函数:

// execute a SVN command and fetch the output as a string
private string ExecuteSVNCommandWithOutput(string SVNCommand)
{
    string output = "";

    try
    {
        using (Process p = new Process())
        {
            p.StartInfo.FileName = "cmd";
            p.StartInfo.Arguments = "/c " + SVNCommand;
            p.StartInfo.RedirectStandardOutput = true; 
            p.Start();

            output = p.StandardOutput.ReadToEnd();
            p.WaitForExit();
        }
    }
    // unexpected error
    catch (Exception ex)
    {
        output = ex.ToString();
    }

    return output;
}

出于您的目的,我将执行以下操作来运行svn log

ExecuteSVNCommandWithOutput(@"svn log C:\Repositories\YourRepositoryName");

然后,您可以将字符串输出解析为数组或某种列表。希望这可以帮助!

于 2018-04-06T13:32:37.377 回答
0

您可以从命令行(或使用 Process 类)调用 svn 日志(http://svnbook.red-bean.com/en/1.7/svn.ref.svn.c.log.html ),将输出重定向到一个文件,然后打开并解析该文件。

解析默认文本输出并不难,但使用 --xml 选项,可以使用任何 XML 库更轻松地解析文件。

于 2018-01-31T20:33:07.233 回答