class ChangelogGenerator::Generator
Attributes
changelog[RW]
Public Instance Methods
generate()
click to toggle source
# File lib/changelog_generator.rb, line 10 def generate Dir.chdir(repo_directory) do `git pull --tags` raw_changelog = `git log last-deploy..HEAD --no-merges --format=%B` self.changelog = format(raw_changelog) send_mail `git tag -f last-deploy` `git push --force origin refs/tags/last-deploy:refs/tags/last-deploy` end end
Private Instance Methods
config()
click to toggle source
# File lib/changelog_generator.rb, line 37 def config @config ||= parse_config end
format(raw)
click to toggle source
# File lib/changelog_generator.rb, line 23 def format(raw) commits = raw.split(/^$\n/) commits.map { |commit| "* " + commit }.join end
message()
click to toggle source
# File lib/changelog_generator.rb, line 45 def message "Subject: #{subject}\n\n#{subject}\n\n#{changelog}" end
parse_config()
click to toggle source
# File lib/changelog_generator.rb, line 41 def parse_config YAML.load_file(config_file) end
send_mail()
click to toggle source
# File lib/changelog_generator.rb, line 28 def send_mail smtp = Net::SMTP.new config["server"], config["port"] smtp.enable_starttls smtp.start(config["domain"], config["user"], config["password"], :login) do smtp.send_message(message, config["user"], config["receivers"]) end end
subject()
click to toggle source
# File lib/changelog_generator.rb, line 49 def subject "Changelog - deployment #{Time.now.strftime("%d/%m/%Y %k:%M")}" end