forked from bettyblocks/betty_resource
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
77 lines (61 loc) · 1.56 KB
/
Rakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
require "bundler/gem_tasks"
require "rake/testtask"
task :default => :test
Rake::TestTask.new do |t|
t.test_files = FileList["test/**/test_*.rb"]
end
desc "Changelog"
task :changelog do
tag = ENV["FROM"] || `git describe --abbrev=0 --tags`.strip
range = [tag, "HEAD"].compact.join ".."
cmd = "git log --no-merges #{range} '--format=tformat:%B|||%aN|||%aE|||'"
now = Time.new.strftime "%Y-%m-%d"
changes = `#{cmd}`.split(/\|\|\|/).each_slice(3).map do |msg, author, email|
msg.split(/\n/).reject { |s| s.empty? }
end
changes = changes.flatten
next if changes.empty?
$changes = Hash.new { |h,k| h[k] = [] }
codes = {
"!" => :major,
"+" => :minor,
"*" => :minor,
"-" => :bug,
"?" => :unknown,
}
codes_re = Regexp.escape codes.keys.join
changes.each do |change|
if change =~ /^\s*([#{codes_re}])\s*(.*)/ then
code, line = codes[$1], $2
else
code, line = codes["?"], change.chomp
end
$changes[code] << line
end
puts "=== #{ENV['VERSION'] || 'NEXT'} / #{now}"
puts
changelog_section :major
changelog_section :minor
changelog_section :bug
changelog_section :unknown
puts
end
def changelog_section code
name = {
:major => "major enhancement",
:minor => "minor enhancement",
:bug => "bug fix",
:unknown => "unknown",
}[code]
changes = $changes[code]
count = changes.size
name += "s" if count > 1
name.sub!(/fixs/, 'fixes')
return if count < 1
puts "* #{count} #{name}:"
puts
changes.sort.each do |line|
puts " * #{line}"
end
puts
end