How to access file information using pre-commit bindings using SharpSVN

I am new to SharpSVN and SVN in general. I am trying to implement a pre-commit hook when a user commits a certain type of XML file; I will need to intercept the file and analyze it to make sure they include certain elements before I allow the file to commit the file.

Since it seems that SVN presents two arguments; storage path and transaction; I will need to use these two elements to intercept the file. Does anyone know what I need to use in SharpSVN to get file information based on these two parameters?

Thanks, Flea

+2
source share
1

, SvnLookClient.

, SvnLookOrigin. SharpSvn , "", hook. SvnLookOrigin:

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

using (SvnLookClient cl = new SvnLookClient())
{
    Collection<SvnChangedEventArgs> changedItems;
    cl.GetChanged(ha.LookOrigin, out changedItems);

    foreach(var item in changedItems)
    {
        if(!IsXmlFile(item)) continue;

        using(MemoryStream ms = new MemoryStream())
        {
            cl.Write(ha.LookOrigin, item.Path, stream);

            VerifyXMLStream(stream);
        }
    }
}

: Console.Error Environment.Exit(1), (exit non-null).

+4

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


All Articles