我正在尝试使用 Octokit.rb 列出 Github 帐户存储库的详细信息,但似乎无法找到关联的 URL。
首先,我需要做的就是使用 OAuth 通过 Github API 进行身份验证,并将详细信息输出到控制台。到目前为止,这是一个基本示例:
client = Octokit::Client.new :access_token => 'my_token'
client.repos.each do |repo|
puts repo.name
puts repo.description
# html_url & clone_url go here.
end
我确定我忽略了一些明显的东西,但是您需要做什么才能找到 html_url
、clone_url
等(根据 API )对于每个存储库?
最佳答案
事实证明这是显而易见的:
client = Octokit::Client.new :access_token => 'my_token'
client.repos.each do |repo|
puts repo.name
puts repo.description
# find the urls
puts repo.rels[:html].href
puts repo.rels[:git].href
puts repo.rels[:clone].href
puts repo.rels[:ssh].href
end
关于ruby - 使用 Octokit.rb 输出 repos URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19742792/