如何在 C# 中使用 SharpSVN 库设置 SVN 提交的作者
我使用来自 CollabNET 的 SharpSvn 库。 我想在提交时设置修订作者,但我总是以我的 Windows 用户名进行提交。
这对我不起作用:
System.Net.NetworkCredential oCred = new
System.Net.NetworkCredential("user", "pass");
client.Authentication.DefaultCredentials = oCred;
我也尝试过:
client.SetProperty("", "svn:author", "user");
但我收到一个错误,目标(第一个参数)不好。
那么你能告诉我如何在 c# 中设置提交到 subversion 存储库的用户(作者)吗?
I use SharpSvn library from CollabNET. I would like to set revision author while commiting, but I always end up with a commit with my Windows user name.
This does not work for me:
System.Net.NetworkCredential oCred = new
System.Net.NetworkCredential("user", "pass");
client.Authentication.DefaultCredentials = oCred;
I've tried also:
client.SetProperty("", "svn:author", "user");
But I get an error that target (first argument) is bad.
So could you please tell me how to set user (author) of commit to subversion repository in c#?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这一切都取决于您如何连接到存储库,因为存储库负责向修订添加用户名。 (它通常会复制连接的凭据,但并非必须这样做)。
当您使用 file:/// 存储库时(通常不推荐 - 请参阅The Subversion Book)您可以直接在提交上解决此问题。
如果连接到远程存储库,则可以在存储库中安装 pre-revprop-change 挂钩时更改修订的作者(请参阅 颠覆书)
[2009-08-14]
最新的 SharpSvn 版本也允许这样做:
最后一个示例假设直接文件访问存储库,但它绕过存储库挂钩以获得最佳性能。
This all depends on how you connect to your repository, as the repository is responsible for adding a username to the revision. (It usually copies the credentials for the connections but it doesn't have to do that).
When you use a file:/// repository (which is usually not recommended - See The Subversion Book) you can work around this directly on the commit.
If you connect to a remote repository you can change the author of a revision when a pre-revprop-change hook is installed in the repository (See The Subversion Book)
[2009-08-14]
More recent SharpSvn releases also allow this:
This last example assumes direct file access to the repository, but it bypasses repository hooks for optimal performance.