Feature #25616 » make-changelog.rb
| 1 |
#!/usr/bin/env ruby
|
|---|---|
| 2 |
|
| 3 |
require 'open-uri' |
| 4 |
require 'nokogiri' |
| 5 |
require 'optparse' |
| 6 |
|
| 7 |
params = ARGV.getopts('', 'version_id:') |
| 8 |
unless params['version_id'] |
| 9 |
STDERR.puts "error: version_id is required." |
| 10 |
exit 1 |
| 11 |
end
|
| 12 |
|
| 13 |
URL = "http://www.redmine.org/projects/redmine/issues?fixed_version_id=#{params['version_id']}&set_filter=1&status_id=%2A" |
| 14 |
|
| 15 |
Issue = Struct.new(:tracker, :id, :subject, :category) |
| 16 |
|
| 17 |
issues = [] |
| 18 |
page = 1 |
| 19 |
while true |
| 20 |
html = open("#{URL}&page=#{page}").read |
| 21 |
doc = Nokogiri::HTML(html) |
| 22 |
rows = doc.css('table.list.issues tbody tr') |
| 23 |
break if rows.empty? |
| 24 |
rows.each do |tr| |
| 25 |
issue = Issue.new |
| 26 |
issue.tracker = tr.css('td.tracker').first.text |
| 27 |
issue.id = tr.css('td.id').first.text |
| 28 |
issue.subject = tr.css('td.subject').first.text.strip |
| 29 |
issue.category = tr.css('td.category').first.text |
| 30 |
issues << issue |
| 31 |
end
|
| 32 |
page += 1 |
| 33 |
end
|
| 34 |
|
| 35 |
issues_by_category = issues.group_by {|item| item.category} |
| 36 |
issues_by_category.keys.sort.each do |category| |
| 37 |
print "\n=== #{category}\n\n" |
| 38 |
issues_by_category[category].sort_by {|v| [v.tracker, v.id.to_i]}.each do |issue| |
| 39 |
puts "* #{issue.tracker} ##{issue.id}: #{issue.subject}" |
| 40 |
end
|
| 41 |
end
|