-
Notifications
You must be signed in to change notification settings - Fork 16
/
floss-changes
executable file
·36 lines (32 loc) · 1.07 KB
/
floss-changes
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
#!/usr/bin/env ruby
#
# Prints release notes ranging from the current branch to the master branch.
#
# Written in 2012 by Suraj N. Kurapati <https://github.com/sunaku>
last_version_tag = `git tag -l`.lines.last.chomp
branches = [:major, :minor, :patch, :other, :master, last_version_tag]
current_branch = `git name-rev --name-only HEAD`.chomp.to_sym
branches.shift branches.index(current_branch)
sections = {}
branches.each_cons(2) do |head, tail|
output = ["### #{head.capitalize}:", nil]
`git log --pretty=medium #{tail}..#{head}`.split(/(?=^commit)/).reverse_each do |log|
commit, message = log.split(/^$/, 2)
output.push " * #{message.strip.sub(/$/, '.').sub(/\A[a-z]/, &:upcase)}", nil
end
sections[head] = output if output.length > 2
end
version = last_version_tag.scan(/\d+/)
if sections.key? :major
version[0].next!
version[1] = '0'
version[2] = '0'
elsif sections.key? :minor
version[1].next!
version[2] = '0'
else
version[2].next!
end
title = "## Version #{version.join('.')} (#{Time.now.strftime('%F')})"
notes = sections.values
puts title, nil, notes