theforeman/foreman-docker

View on GitHub
release/changelog

Summary

Maintainability
Test Coverage
#!/usr/bin/env ruby
# Taken from foreman core (https://github.com/theforeman/foreman)
# changelog generates two files, Contributors and CHANGELOG with all changes
# from git. These should be included in every foreman-docker release.

cmd = `git log --pretty='format:%ci::%an <%ae>::%s'`

list = {}
list_order = []
contributors = []
changelog_file = "CHANGELOG"
contributors_file = "Contributors"

cmd.each_line do |l|
  date, author, subject = l.chomp.split("::")
  date, _time, _zone = date.split(" ")

  id = "#{date}\t#{author}"
  unless list[id]
    list[id] = []
    list_order << { :id => id, :value => list[id] }
  end
  list[id] << subject
  contributors << author
end

# list.each do |id, value|
file = File.new(changelog_file, "w")
list_order.each do |i|
  id = i[:id]
  value = i[:value]

  file.puts "#{id}"
  file.puts value.map { |e| "\t* #{e}" }.join("\n")
  file.puts "\n"
end
file.close
file = File.new(contributors_file, "w")
file.puts "Contributors (sorted alphabetically)"
file.puts "\n"
file.puts contributors.sort.uniq.join("\n")
file.close