Ruby で github のリポジトリの最新のコミットハッシュを取得する

だいぶ前になりますが Lingr で raa さんに教えてもらったので覚書。
Rubygithub のあれこれを取得する場合、Octokit を利用するとよさそう。

[ソース]

require 'octokit'

# リポジトリの最新のコミットハッシュを取得
puts Octokit.list_commits("osyo-manga/vim-over").first['sha']

# URL 指定してコミットハッシュを取得したい場合
repo = Octokit::Repository.from_url("https://github.com/osyo-manga/vim-over/blob/master/README.md")
puts Octokit.list_commits(repo).first['sha']

[出力]

7bf29a7306860f30a4daf15a5daf5c792028e093
7bf29a7306860f30a4daf15a5daf5c792028e093