SharpSVN gets post-commit-hook using 'SvnLookClient'

I am trying to figure out how to get a commit message for a specific version. It seems that SvnLookClient is what I need

I found code here on SO that looks the way I need it, but I seem to be missing something.

The code I found (like this):

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)
    {

    }
}
+3
source share
3 answers

The SvnLook client is specifically designed for use in repository entries. It allows you to access unjustified versions and, therefore, needs other arguments. (This is the SharpSvn equivalent of the svnlook command. If you need the equivalent of 'svn', you should look at SvnClient).

: * *

. , URL-, .

( 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 , :

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

. ( , . Subversion). , , .LookOrigin ha.

(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))
}
+3

FYI, #, . , !

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;
}
+1

No, I think I have a code for this, I will send it later. SharpSVN has a possibly (IMHO) confusing API.

I think you need .Log (from SvnClient) or similar passing in your revision.

0
source

Source: https://habr.com/ru/post/1714830/


All Articles