Skip to content

Instantly share code, notes, and snippets.

@robink
Last active December 17, 2015 06:58
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robink/5568944 to your computer and use it in GitHub Desktop.
Save robink/5568944 to your computer and use it in GitHub Desktop.
Show the "changelog" / "releases notes" of a given repo. Relies on Pull Requests descriptions (as they are editables) and printing only when their title contains "#changelog".
require 'highline/import'
require 'github_api'
login = ask("Login: ")
password = ask("Password: ") { |q| q.echo = false }
owner = ask("Repo owner: ")
repo_name = ask("Repo name: ")
def print_changelog( repo, pr )
print_pr(repo, pr) if pr.title.gsub!(/#changelog/, '')
end
def print_pr( repo, pr )
date_at = Date.rfc3339( pr.merged_at ? pr.merged_at : pr.updated_at )
users = repo.pull_requests.commits( number: pr["number"]).map{ |commit| commit["author"].nil? ? "" : commit["author"]["login"] }
users.uniq!
puts "[" + date_at.strftime('%d/%m/%Y') + "] " + pr.title.strip.upcase
puts "Authors: " + users.join(", ")
puts pr.body
puts ""
end
repo = Github.new login: login, password: password, user: owner, repo: repo_name
pull_requests = repo.pull_requests
puts "### CHANGELOG ###"
puts ""
puts "----------------"
puts "UPCOMING CHANGES"
puts ""
pull_requests.list.each{ |pr| print_changelog( repo, pr ) }
puts "----------------"
puts "RELEASED"
puts ""
pull_requests.list( state: "closed" ).each do |pr|
if pull_requests.merged?( owner, repo_name, pr.number)
print_changelog( repo, pr )
end
end
source 'https://rubygems.org'
gem "github_api"
gem "highline"
@robink
Copy link
Author

robink commented May 13, 2013

AFAIK it lacks pagination handling.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment