Last active
December 17, 2015 06:58
-
-
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".
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
gem "github_api" | |
gem "highline" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
AFAIK it lacks pagination handling.