Sha256: d28eafbfb0bc66a8c4fd704be4599b9161abe48c80b25c726cb5a013fdaf5ab8
Contents?: true
Size: 1.48 KB
Versions: 1
Compression:
Stored size: 1.48 KB
Contents
require 'structured_changelog' require 'structured_changelog/core_ext/string' require 'structured_changelog/core_ext/gem' require 'git' task "changelog:compile", [:repo_path, :changelog_path] do |_task, arguments| repo_path = arguments.to_h.fetch(:repo_path) { Pathname.pwd } changelog_path = arguments.to_h.fetch(:changelog_path) { Pathname.pwd/"CHANGELOG.md" } current_version = StructuredChangelog.new(changelog_path).version repo = Git.open(repo_path) commit_messages = repo.log.since("v#{current_version}").map(&:message).select do |message| message.match?(/^\[CHANGELOG\]\n\n\*\ /) end abort("No [CHANGELOG] commits since the last release") if commit_messages.empty? message = commit_messages.flat_map do |message| message.sub(/^\[CHANGELOG\]\n\n/, "") end.join("\n") new_version = if message.match?(/^*\ BREAKING:/) current_version.bump_major elsif message.match?(/^*\ FEATURE:/) current_version.bump_minor elsif message.match?(/^*\ FIX:/) current_version.bump_patch elsif message.match?(/^*\ ENHANCEMENT:/) current_version.bump_patch elsif message.match?(/^*\ DEPRECATION:/) current_version.bump_patch end changelog_path.write( changelog_path.read.sub( /^##\ RELEASE\ #{current_version}/, "## RELEASE #{new_version}\n\n#{message}\n\n## RELEASE #{current_version}" ) ) end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
structured_changelog-0.10.0 | lib/structured_changelog/tasks/compile.rb |