首页 > 解决方案 > 在 ruby​​ 中使用 octokit 在 github 中检索最新的发布版本和最后 3 个各自的提交

问题描述

我试图自动化 GitHub 流程并获取 ruby​​ 中存储库的最新发布版本名称和各自的最后 3 次提交。我已经使用 octokit gem 来实现这一点。但我无法获得发布版本 ID 或版本名称。谁能帮我解决这个问题?

require 'highline/import'
require 'octokit'

# API
ratelimit           = Octokit.ratelimit
ratelimit_remaining = Octokit.ratelimit_remaining
puts "Rate Limit Remaining: #{ratelimit_remaining} / #{ratelimit}"
 
#authenticates userid and pwd for the github
$userid = ask("Enter your username:  ") { |q| q.echo = true }
$passwd = ask("Enter your password:  ") { |q| q.echo = "*" }

#client holds the complete github information of that particular user 
client = Octokit::Client.new(:login => $userid, :password => $passwd)

#repos hold all the client repositories
repos= client.repositories

#this will fetch the info of the particluar repo
repos1= repos[5]['name']
puts "Last 3 commits for #{repos1} are"
Octokit.list_commits("kvsushma/#{repos1}").first(3).map do |a|
   puts  " #{a.commit['message']} "
end

这给出了正确的信息。但是当我尝试运行代码以获取最新版本时,它会给出错误。

 var releases = client.Repository.Release.GetAll("octokit", "octokit.net");
 var latest = releases[0];
 Console.WriteLine(
    "The latest release is tagged at {0} and is named {1}", 
     latest.TagName, 
    latest.Name);

参考链接在此处输入链接描述

标签: rubygithuboctokit

解决方案


推荐阅读