Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby Svn::Client::Context中的status方法能否返回数组_Ruby_Svn - Fatal编程技术网

Ruby Svn::Client::Context中的status方法能否返回数组

Ruby Svn::Client::Context中的status方法能否返回数组,ruby,svn,Ruby,Svn,我试图使用ruby的SVN绑定来获取文件的提交日期。下面的代码可以工作。然而,我并不满足于我需要使用一个块来从status方法获得结果这一事实。有更好的办法吗 ctx = Svn::Client::Context.new() ctx.add_simple_prompt_provider(2) do |cred, realm, user_name, may_save| cred.username = "sorin" cred.password = "realyniftypassword"

我试图使用ruby的SVN绑定来获取文件的提交日期。下面的代码可以工作。然而,我并不满足于我需要使用一个块来从status方法获得结果这一事实。有更好的办法吗

ctx = Svn::Client::Context.new()
ctx.add_simple_prompt_provider(2) do |cred, realm, user_name, may_save|
  cred.username = "sorin"
  cred.password = "realyniftypassword"
end

svndate = nil
ctx.status(path, "HEAD", true, true) do |path, status| 
    break if status.entry.nil?
    svndate = status.entry.cmt_date
end 

next if svndate.nil?
我要找的东西是:

svndate = ctx.status(path, "HEAD", true, true)[0].entry.cmt_date
但是ctx.status返回一个整数

有没有更合适的方法


我使用的是ubuntudeb包libsvn-ruby1.8,除了网络上的几个例子外,我找不到任何关于它的文档

作为将来的参考,有一个Ruby gem可能会有所帮助



你用的是哪种装订?你有文档的链接吗?嗯,基于这两个问题:“我正在尝试使用ruby的SVN绑定来获取文件的提交日期,…”和“是否有更合适的方法?”我回答了这个问题。我的回答是,我觉得有一个更合适的方法。svn_wc ruby gem使用ruby svn绑定进一步简化了操作。我提供的代码将打印“HEAD”中每个条目的提交日期。我很抱歉,如果这不是你想要的,但是根据你的问题提供的似乎是有效的答案似乎不合适而被否决。
require 'svn_wc'
conf = {
  "svn_repo_master"       => "svn+ssh://sorin@192.168.10.1/opt/repo",
  "svn_user"              => "sorin",
  "svn_pass"              => "realyniftypassword",
  "svn_repo_working_copy" => "/tmp/local_working_repo/root",
  #"svn_repo_config_path"  => "/tmp/my_config"
}

svn = SvnWc::RepoAccess.new YAML::dump(conf)
repo_wc = conf['svn_repo_working_copy']
svn.list_entries(repo_wc, nil, verbose=true).each do |info|
  puts "#{info[:entry_name]} #{info[:cmt_date]}"
end