Last active
December 22, 2016 04:34
-
-
Save 1160054/3fd40f6a1db3947fecc489dbfae2a952 to your computer and use it in GitHub Desktop.
リリースノートを作るRubyスクリプト ref: http://qiita.com/___dera/items/1bcc5dd42991b9600cb6
This file contains 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
brew install chrome-cli |
This file contains 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
rails c | |
pry > load "Desktop/note.rb" |
This file contains 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 'nokogiri' | |
s=3 | |
# MergeコミットのPRのURLを取得 | |
pull_urls = Nokogiri::HTML.parse(`chrome-cli source`).css('a').map { |m| m.attr(:href) }.grep(/pull\/\d+\Z/).uniq.compact | |
puts pull_urls.count | |
idx = 0 | |
# PRのURLから、IssueのURLを取得 | |
issues_urls = pull_urls.map { |m| | |
puts idx+=1 | |
`chrome-cli open #{m}` | |
sleep(s) | |
url= Nokogiri::HTML.parse(`chrome-cli source`).css('a').map { |m| m.attr(:href) }.grep(/issues\/\d+\Z/) | |
`chrome-cli close` | |
url | |
}.flatten.uniq.compact | |
idx=0 | |
# IssueのURLからタイトルとURLと、ひも付けられているPRのURLを取得 | |
issue_describe = issues_urls.map{ |m| | |
puts idx+=1 | |
url = m[0] == '/' ? "https://github.com#{m}" : m | |
`chrome-cli open #{url}` | |
sleep(s) | |
doc = Nokogiri::HTML.parse(`chrome-cli source`) | |
items = doc.css(".discussion-item-rollup-ref") | |
merge_pull = items.map do |item| | |
item.css("span").text =~ /Merged/ ? item.css("h4 > a").map{ |e| "[#{e.text}](#{e.attr(:href)})" } : [] | |
end | |
arr = [doc.title, url, merge_pull.uniq.compact.join('<br>')] | |
`chrome-cli close` | |
arr | |
} | |
$issue = issue_describe | |
# マークダウンのテーブル形式で表示する | |
puts "| Title | Issue | Pull-request |" | |
puts "|:---:|---|---|" | |
puts $issue.map{ |m| | |
next if m.first =~ /Pull Request #\d{1,5}/ | |
"| #{m.map{ |s| s.gsub(/\s/,'') }.join(' | ')} |" | |
}.compact |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment