subversion ruby 绑定可以使用用户存储的凭据吗?
我正在编写一个跨平台 ruby 脚本来管理一些 subversion 存储库。我最初生成了 bash 命令,但事实证明这对 Windows 非常不友好。然后我重写了我的脚本以使用 subversion 提供的 SWIG ruby 绑定。这在使用 ruby 1.8.7 的所有必需平台(Ubuntu、Fedora、OS X、Windows)上完美运行(就 SVN 操作而言)。
我使用 svn_wc gem 来抽象部分绑定,因为我不但了解低级代码。
现在,我的问题是我必须将用户的凭据提供给绑定。 svn_wc使用此代码 :
ctx.add_simple_prompt_provider(0) do |cred, realm, username, may_save|
cred.username = @svn_user
cred.password = @svn_pass
cred.may_save = false
end
如果 @svn_user
和 @svn_pass
为零,则绑定会因分段错误而失败:
~/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/svn/util.rb:86:
[BUG] Segmentation fault
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.8.0]
[1] 4381 abort my_script.rb
如果我评论整段代码,我的 svn 命令失败并出现以下错误:
cant get info: subversion/libsvn_ra_neon/util.c:608:
Svn::Error::RaNotAuthorized: OPTIONS of 'https://my.subversion.url':
authorization failed: Could not authenticate to server:
rejected Basic challenge (https://my.subversion.url) (SvnWc::RepoAccessError)
我不知道 may_save
参数的用途。将其更改为 true 并且不提供凭据仍然会产生分段错误。
我的脚本应该像命令行二进制文件一样使用存储的加密凭据。我不想每次都输入凭据或将它们存储在未加密的配置文件中。
我没有找到任何关于此的文档。有谁知道是否可能以及如何实现?
I'm writing a cross-platform ruby script to manage some subversion repositories. I initially generated bash commands but this proved to be very Windows-unfriendly. I then rewrote my script to use the SWIG ruby bindings provided with subversion. This works perfectly (as far as SVN operations are concerned) on all required platforms (Ubuntu, Fedora, OS X, Windows) with ruby 1.8.7.
I use the svn_wc gem to abstract part of the bindings because I don't yet understand the low-level code.
Now, my problem is that I have to give the user's credentials to the bindings. svn_wc uses this code:
ctx.add_simple_prompt_provider(0) do |cred, realm, username, may_save|
cred.username = @svn_user
cred.password = @svn_pass
cred.may_save = false
end
If @svn_user
and @svn_pass
are nil, the bindings fail with a segmentation fault:
~/.rvm/rubies/ruby-1.8.7-p334/lib/ruby/1.8/svn/util.rb:86:
[BUG] Segmentation fault
ruby 1.8.7 (2011-02-18 patchlevel 334) [i686-darwin10.8.0]
[1] 4381 abort my_script.rb
If I comment this whole piece of code, my svn command fails with the following error:
cant get info: subversion/libsvn_ra_neon/util.c:608:
Svn::Error::RaNotAuthorized: OPTIONS of 'https://my.subversion.url':
authorization failed: Could not authenticate to server:
rejected Basic challenge (https://my.subversion.url) (SvnWc::RepoAccessError)
I don't know what the may_save
parameter is for. Changing it to true and giving no credentials still produces the segmentation fault.
My script should use the stored, encrypted credentials the same way the command line binary does. I don't want to type the credentials every time or to store them in a unencrypted configuration file.
I have found no documentation about this. Does anyone know if it's possible and how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论