Skip to content

Octokit Documentation

jeffWelling edited this page Apr 27, 2011 · 4 revisions

###Octokit Documentation Because Octokit, like so many other Git ruby gems, has so little documentation at the time of this writing (April 18 2011), I've had to create my own documentation.

All of the tidbits below assume that you have already instantiated the client with
client= Octokit::Client.new({ :username=> "jeffWelling", :token => "omgwtfbbq..." })
where the :username and :token values are replaced with your username and Github API token.

How to get issues

The client.issues(repo) call returns an array of all Github Issues as Hashie::Mash objects.

irb(main):009:0> issues=client.issues("jeffWelling/ticgit")

The Octokit Full Documentation page for client.issues(repo, state='open',, options={}) tells us that if you want to get closed issues you have to use client.issues(repo, 'closed').

Here, we use ruby pretty print to show one of the issue objects. Don't forget to require 'pp'.

irb(main):010:0> pp issues[0]
{"gravatar_id"=>"c787da56bc64ea702d58067f880b3212",
"position"=>1.0,
"number"=>4,
"votes"=>0,
"created_at"=>"2010/11/19 07:13:40 -0800",
"comments"=>2,
"body"=>
"When I add comment, through console, it doesn't appear when I reload ticgitweb page. (It is running locally)",
"title"=>"Comments issue",
"updated_at"=>"2011/04/11 03:20:39 -0700",
"html_url"=>"https://github.com/jeffWelling/ticgit/issues/4",
"user"=>"romanoff",
"labels"=>["Bug"],
"state"=>"open"}
=> nil

Getting comments for an issue

The client.issue_comments(repo, issue_num) call returns comments as an array of Hashie::Mash objects.

irb(main):007:0> pp client.issue_comments("jeffWelling/ticgit", 4)
[{"gravatar_id"=>"96be9ea59dea46616afed434fd07dcf5",
"created_at"=>"2011/02/28 16:20:17 -0800",
"body"=>
"Because my priorities are currently with the console command and not with ticgitweb, I don't plan on resolving this issue in the immediate future.\r\nI will leave this issue open as a reminder though for when my priorities allow me to spend time on it.",
"updated_at"=>"2011/02/28 16:20:17 -0800",
"id"=>820476,
"user"=>"jeffWelling"},
{"gravatar_id"=>"96be9ea59dea46616afed434fd07dcf5",
"created_at"=>"2011/04/11 03:20:39 -0700",
"body"=>
"I just fixed a problem with ticgitweb not running, so while I'm still ticgitweb-ing, I'll take a look at this as well.",
"updated_at"=>"2011/04/11 03:20:39 -0700",
"id"=>982929,
"user"=>"jeffWelling"}]
=> nil

Clone this wiki locally