1
|
#!/usr/bin/env ruby
|
2
|
# Taken from foreman core (https://github.com/theforeman/foreman)
|
3
|
# changelog generates two files, Contributors and CHANGELOG with all changes
|
4
|
# from git. These should be included in every foreman-docker release.
|
5
|
|
6
|
|
7
|
cmd=`git log --pretty='format:%ci::%an <%ae>::%s'`
|
8
|
|
9
|
list = {}
|
10
|
list_order = []
|
11
|
contributors = []
|
12
|
changelog_file = "CHANGELOG"
|
13
|
contributors_file = "Contributors"
|
14
|
|
15
|
cmd.each_line do |l|
|
16
|
date, author, subject = l.chomp.split("::")
|
17
|
date, _time, _zone = date.split(" ")
|
18
|
|
19
|
id = "#{date}\t#{author}"
|
20
|
if not list[id]
|
21
|
list[id] = []
|
22
|
list_order << {:id => id, :value => list[id]}
|
23
|
end
|
24
|
list[id] << subject
|
25
|
contributors << author
|
26
|
end
|
27
|
|
28
|
# list.each do |id, value|
|
29
|
file = File.new(changelog_file,"w")
|
30
|
list_order.each do |i|
|
31
|
id = i[:id]
|
32
|
value = i[:value]
|
33
|
|
34
|
file.puts "#{id}"
|
35
|
file.puts value.map { |e| "\t* #{e}" }.join("\n")
|
36
|
file.puts "\n"
|
37
|
end
|
38
|
file.close
|
39
|
file = File.new(contributors_file,"w")
|
40
|
file.puts "Contributors (sorted alphabetically)"
|
41
|
file.puts "\n"
|
42
|
file.puts contributors.sort.uniq.join("\n")
|
43
|
file.close
|