Skip to content

Instantly share code, notes, and snippets.

@morkeleb
Created February 16, 2016 12:12
Show Gist options
  • Save morkeleb/57670226064f0a7492f4 to your computer and use it in GitHub Desktop.
Save morkeleb/57670226064f0a7492f4 to your computer and use it in GitHub Desktop.
Latest change date for an organisations repositories
require "github_api"
user = 'username'
token = 'oauth access token obtained from user settings'
organisation = 'myorg'
Github.configure do |c|
c.basic_auth = "#{user}:#{token}"
c.oauth_token = token
end
class Commit
attr_accessor :repo, :date, :message
end
github = Github.new
repos = github.repos.list org: organisation
list = repos.auto_paginate(true).map { |repo|
c = Commit.new
c.repo = repo.name
c.date = "1990-10-10"
begin
r = github.repos.commits.list organisation, repo.name
commit = r.first.commit
c.date = commit.author.date
c.message = commit.message
rescue
end
c
}.sort_by {|x| x.date}
list.each { |c|
p "#{c.date} - #{c.repo} : #{c.message}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment