Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Output a repos URLs using Octokit.rb

I'm attempting to list details of a Github accounts repos using Octokit.rb, but can't seem to find the associated URLs.

In the first instance all I need to do is authenticate with the Github API using OAuth and output the details to the console. Here's a basic example so far:

client = Octokit::Client.new :access_token => 'my_token'

client.repos.each do |repo|
    puts repo.name
    puts repo.description
    # html_url & clone_url go here.
end

I'm sure I've overlooked something obvious, but what do you need to do to find the html_url, clone_url etc (as per the API) for each repository?

like image 489
Matt Weldon Avatar asked Nov 02 '13 14:11

Matt Weldon


1 Answers

Turns out it was obvious after all:

client = Octokit::Client.new :access_token => 'my_token'

client.repos.each do |repo|
    puts repo.name
    puts repo.description

    # find the urls
    puts repo.rels[:html].href
    puts repo.rels[:git].href
    puts repo.rels[:clone].href
    puts repo.rels[:ssh].href
end
like image 193
Matt Weldon Avatar answered Oct 13 '22 23:10

Matt Weldon