Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

first_github_commit

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

first_github_commit

  • 0.1.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= 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"=> "http://github.com/thoughtbot/shoulda/commit/37686ae0dadb3a820db039a9ab3d024983034e7f", "id"=>"37686ae0dadb3a820db039a9ab3d024983034e7f", "committed_date"=>"2007-03-14T11:11:47-07:00", "message"=>"Created trunk and tags (...)",
(...)}

The data returned is that from the GitHub commit listing API, see http://develop.github.com/p/commits.html

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

c = FirstGithubCommit.new('thoughtbot', 'shoulda') c.yaml => {"author"=> ... } # Same as above c.page => 14

Get the url for the github commit listing web interface

c.github_url => "http://github.com/thoughtbot/shoulda/commits/master?page=14"

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.

== TODO

  • 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

Copyright (c) 2010 Christoph Olszowka. See LICENSE for details.

FAQs

Package last updated on 12 Oct 2010

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc