2012-11-10 20:33:12 -05:00
|
|
|
require "rake"
|
|
|
|
require "rake/tasklib"
|
|
|
|
|
|
|
|
module Fog
|
|
|
|
module Rake
|
|
|
|
class ChangelogTask < ::Rake::TaskLib
|
|
|
|
|
|
|
|
def initialize
|
|
|
|
desc "Update the changelog since the last release"
|
|
|
|
task(:changelog) do
|
|
|
|
timestamp = Time.now.utc.strftime('%m/%d/%Y')
|
|
|
|
sha = `git log | head -1`.split(' ').last
|
|
|
|
changelog = ["#{Fog::VERSION} #{timestamp} #{sha}"]
|
|
|
|
changelog << ('=' * changelog[0].length)
|
|
|
|
changelog << ''
|
|
|
|
|
|
|
|
github_repo_data = Fog::JSON.decode(Excon.get('https://api.github.com/repos/fog/fog').body)
|
|
|
|
data = github_repo_data.reject {|key, value| !['forks', 'open_issues', 'watchers'].include?(key)}
|
|
|
|
github_collaborator_data = Fog::JSON.decode(Excon.get('https://api.github.com/repos/fog/fog/collaborators').body)
|
|
|
|
data['collaborators'] = github_collaborator_data.length
|
|
|
|
rubygems_data = Fog::JSON.decode(Excon.get('https://rubygems.org/api/v1/gems/fog.json').body)
|
|
|
|
data['downloads'] = rubygems_data['downloads']
|
|
|
|
stats = []
|
|
|
|
for key in data.keys.sort
|
|
|
|
stats << "'#{key}' => #{data[key]}"
|
|
|
|
end
|
|
|
|
changelog << "Stats! { #{stats.join(', ')} }"
|
|
|
|
changelog << ''
|
|
|
|
|
|
|
|
last_sha = `cat changelog.txt | head -1`.split(' ').last
|
|
|
|
shortlog = `git shortlog #{last_sha}..HEAD`
|
|
|
|
changes = {}
|
|
|
|
committers = {}
|
|
|
|
for line in shortlog.split("\n")
|
|
|
|
if line =~ /^\S/
|
|
|
|
committer = line.split(' (', 2).first
|
|
|
|
committers[committer] = 0
|
|
|
|
elsif line =~ /^\s*((Merge.*)|(Release.*))?$/
|
|
|
|
# skip empty lines, Merge and Release commits
|
|
|
|
else
|
|
|
|
unless line[-1..-1] == '.'
|
|
|
|
line << '.'
|
|
|
|
end
|
|
|
|
line.lstrip!
|
|
|
|
line.gsub!(/^\[([^\]]*)\] /, '')
|
|
|
|
tag = $1 || 'misc'
|
|
|
|
changes[tag] ||= []
|
|
|
|
changes[tag] << (line << ' thanks ' << committer)
|
|
|
|
committers[committer] += 1
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
for committer, commits in committers.to_a.sort {|x,y| y[1] <=> x[1]}
|
|
|
|
if [
|
|
|
|
'Aaron Suggs',
|
|
|
|
'Brian Hartsock',
|
|
|
|
'Christopher Oliver',
|
|
|
|
'Decklin Foster',
|
|
|
|
'Dylan Egan',
|
|
|
|
'geemus',
|
|
|
|
'Henry Addison',
|
|
|
|
'Kevin Menard',
|
2013-04-04 16:39:33 -04:00
|
|
|
'Kyle Rames',
|
2012-11-10 20:33:12 -05:00
|
|
|
'Lincoln Stoll',
|
|
|
|
'Luqman Amjad',
|
|
|
|
'Michael Zeng',
|
2013-05-04 15:16:35 -04:00
|
|
|
'Nat Welch',
|
2012-11-10 20:33:12 -05:00
|
|
|
'Nick Osborn',
|
|
|
|
'nightshade427',
|
|
|
|
'Patrick Debois',
|
2013-01-19 13:15:54 -05:00
|
|
|
'Paul Thornthwaite',
|
2013-03-05 12:27:28 -05:00
|
|
|
'Rupak Ganguly',
|
2012-11-10 20:33:12 -05:00
|
|
|
'Stepan G. Fedorov',
|
|
|
|
'Wesley Beary'
|
|
|
|
].include?(committer)
|
|
|
|
next
|
|
|
|
end
|
|
|
|
changelog << "MVP! #{committer}"
|
|
|
|
changelog << ''
|
|
|
|
break
|
|
|
|
end
|
|
|
|
|
|
|
|
for tag in changes.keys.sort
|
|
|
|
changelog << ('[' << tag << ']')
|
|
|
|
for commit in changes[tag]
|
|
|
|
changelog << (' ' << commit)
|
|
|
|
end
|
|
|
|
changelog << ''
|
|
|
|
end
|
|
|
|
|
|
|
|
old_changelog = File.read('changelog.txt')
|
|
|
|
File.open('changelog.txt', 'w') do |file|
|
|
|
|
file.write(changelog.join("\n"))
|
|
|
|
file.write("\n\n")
|
|
|
|
file.write(old_changelog)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|