First Github Commit

Makes finding the very first commit to a GitHub repo very simple:

gem install first_github_commit

Then you can do the following:

require 'first_github_commit'
require 'pp'
pp FirstGithubCommit.find('thoughtbot', 'shoulda')
=>  {"author"=> { ... }
     "url"=> "",
     "message"=>"Created trunk and tags (...)",       

The data returned is that from the GitHub commit listing API, see

If you also want to know the page number, try this:

c ='thoughtbot', 'shoulda')
c.yaml => {"author"=> ... } # Same as above => 14
# Get the url for the github commit listing web interface
c.github_url => ""

The page number is being retrieved by first finding the highest non-available page number. Starting from page 100, the limit is being doubled on consecutive requests until the GitHub API returns a 404. Then, the chunk is split in half and traversed further until the actual last page is found, from which the last commit is being retrieved then.

The web request limit is 30 consecutive requests, after which a FirstGithubCommit::TooManyRequests exception will be thrown.

Set FirstGithubCommit::DEBUG to true to get some debug output about the requests and the traversal.


  • Optimize the page retrieval

  • Better error handling

  • Make sure the repo exists before proceeding

Note on Patches/Pull Requests

  • Fork the project.

  • Make your feature addition or bug fix.

  • Add tests for it. This is important so I don't break it in a future version unintentionally.

  • Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)

  • Send me a pull request. Bonus points for topic branches.

Copyright © 2010 Christoph Olszowka. See LICENSE for details.