SharpSVN使用"SvnLookClient"获取提交后挂接 [英] SharpSVN get post-commit-hook with 'SvnLookClient'

查看:119
本文介绍了SharpSVN使用"SvnLookClient"获取提交后挂接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试弄清楚如何获取特定修订版的提交消息.看起来SvnLookClient可能是我所需要的

I'm trying to figure out how to get the commit message for a particular revision. It looks like SvnLookClient is probably what I need

我在SO上找到了一些代码,看起来像我所需要的,但是我似乎缺少了一些东西.

I found some code here on SO that looks like what I need but I seem to be missing something..

我找到的代码(在这里如此):

Code I found (here on 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)
    {

    }
}

推荐答案

SvnLook客户端专门用于在存储库挂钩中使用.它允许访问未提交的修订,因此需要其他参数. (这是SharpSvn的"svnlook"命令的等效项.如果您需要"svn"的等效项,则应查看SvnClient).

The SvnLook client is specifically targetted for using in repository hooks. It allows access to uncommited revisions and therefore needs other arguments. (It's the SharpSvn equivalent of the 'svnlook' command. If you need a 'svn' equivalent you should look at SvnClient).

外观来源为: *储存库路径和交易名称 *或存储库路径和修订号

A look origin is either: * A repository path and a transaction name * or a repository path and a revision number

例如在预提交的钩子中,修订尚未提交,因此您不能像通常那样通过公共URL对其进行访问.

E.g. in a pre-commit hook the revision is not committed yet, so you can't access it over the public url, like you would normally do.

文档说(在pre-commit.tmpl中):

The documentation says (in pre-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通过提供以下帮助来帮助您

SharpSvn helps you by offering:

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

哪个为您解析这些参数. (在这种情况下,这很简单,但是有更多高级的钩子.而且,钩子可以在较新的Subversion版本中接收新的参数).您需要的值位于ha的.LookOrigin属性中.

Which parses these arguments for you. (Which in this case is very simple, but there are more advanced hooks.. And hooks can receive new arguments in newer Subversion versions). The value you need is in the .LookOrigin property of ha.

如果您只想获取特定修订范围(1234-4567)的日志消息,则不要查看SvnLookClient.

If you just want to have the log message for a specific revision range (1234-4567) you should not look at the 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))
}

这篇关于SharpSVN使用"SvnLookClient"获取提交后挂接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆