How to set the author of an SVN transaction using the SharpSVN library in C #

I am using the SharpSvn library from CollabNET. I would like to ask the revision author during commits, but I always get a commit with my Windows username.

This does not work for me:

System.Net.NetworkCredential oCred = new
    System.Net.NetworkCredential("user"​, "pass");
client.Authentication.DefaultCredentials = oCred;

I also tried:

client.SetProperty("", "svn:author", "user");

But I get an error that the target (first argument) is bad.

Could you tell me how to install the user (author) commit into the subversion repository in C #?

+3
source share
1 answer

, , . ( , ).

:/// ( - . The Subversion Book), .

using (SvnClient client = new SvnClient())
{
    client.Authentication.Clear(); // Clear predefined handlers

    // Install a custom username handler
    client.Authentication.UserNameHandlers +=
        delegate(object sender, SvnUserNameEventArgs e)
        {
            e.UserName = "MyName";
        };

    SvnCommitArgs ca = new SvnCommitArgs { LogMessage = "Hello" }
    client.Commit(dir, ca);
}

, , (. Subversion )

using (SvnClient client = new SvnClient())
{
    client.SetRevisionProperty(new Uri("http://my/repository"), 12345,
                              SvnPropertyNames.SvnAuthor,
                              "MyName");

    // Older SharpSvn releases allowed only the now obsolete syntax
    client.SetRevisionProperty(
        new SvnUriTarget(new Uri("http://my/repository"), 12345),
        SvnPropertyNames.SvnAuthor,
        "MyName");

}

[2009-08-14] SharpSvn :

using (SvnRepositoryClient rc = new SvnRepositoryClient())
{
   SvnSetRevisionPropertyRepositoryArgs ra;
   ra.CallPreRevPropChangeHook = false;
   ra.CallPostRevPropChangeHook = false;
   rc.SetRevisionProperty(@"C:\Path\To\Repository", 12345,
                         SvnPropertyNames.SvnAuthor, "MyName", ra);
}

, .

+7

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


All Articles