-->

SharpSVN得到的post-commit钩与 'SvnLookClient'(S

2019-09-22 23:42发布

我试图找出如何得到一个特定版本的提交信息。 它看起来像SvnLookClient可能是我所需要的

我发现这里的SO一些代码,看起来像我需要什么,但我似乎失去了一些东西..

代码我发现(在这里如此):

using (SvnLookClient cl = new SvnLookClient())
{
    SvnChangeInfoEventArgs ci;

     //******what is lookorigin? do I pass the revision here??
    cl.GetChangeInfo(ha.LookOrigin, out ci);


    // ci contains information on the commit e.g.
    Console.WriteLine(ci.LogMessage); // Has log message

    foreach (SvnChangeItem i in ci.ChangedPaths)
    {

    }
}

Answer 1:

所述客户端svnlook的具体针对性用于使用在存储库钩。 它允许访问未提交的修改,因此需要其他参数。 (这是SharpSvn相当于使用“svnlook”的命令。如果你需要一个“svn的”相当于你应该看看SvnClient)。

一看产地可以是:* A库路径和事务名*或库路径和版本号

例如在pre-commit钩子的修订尚未提交,所以你不能访问它在公共URL,就像你通常会做。

该文件说,(预commit.tmpl):

# The pre-commit hook is invoked before a Subversion txn is
# committed.  Subversion runs this hook by invoking a program
# (script, executable, binary, etc.) named 'pre-commit' (for which
# this file is a template), with the following ordered arguments:
#
#   [1] REPOS-PATH   (the path to this repository)
#   [2] TXN-NAME     (the name of the txn about to be committed)

SharpSvn帮助您提供:

SvnHookArguments ha; 
if (!SvnHookArguments.ParseHookArguments(args, SvnHookType.PostCommit, false, out ha))
{
    Console.Error.WriteLine("Invalid arguments");
    Environment.Exit(1);  
}

这解析这些参数为您服务。 (在这种情况下是很简单的,但也有更先进的挂钩。而挂钩可以更新的Subversion版本接收新的参数)。 你需要的值是HA的.LookOrigin财产。

如果你只是想有一个特定版本范围(1234-4567)的日志信息,你不应该看SvnLookClient。

using(SvnClient cl = new SvnClient())
{
  SvnLogArgs la = new SvnLogArgs();
  Collection<SvnLogEventArgs> col;
  la.Start = 1234;
  la.End = 4567;
  cl.GetLog(new Uri("http://svn.collab.net/repos/svn"), la, out col))
}


Answer 2:

仅供参考,我做了基于Bert的响应C#功能。 感谢伯特!

public static string GetLogMessage(string uri, int revision)
{
    string message = null;

    using (SvnClient cl = new SvnClient())
    {
        SvnLogArgs la = new SvnLogArgs();
        Collection<SvnLogEventArgs> col;
        la.Start = revision;
        la.End = revision;
        bool gotLog = cl.GetLog(new Uri(uri), la, out col);

        if (gotLog)
        {
            message = col[0].LogMessage;
        }
    }

    return message;
}


Answer 3:

是啊,不,我想我有这个代码,我将在后面张贴。 SharpSVN有争论(恕我直言)混乱的API。

我想你想.LOG(SvnClient的),或类似的,传递你以后的修订。



文章来源: SharpSVN get post-commit-hook with 'SvnLookClient'