Skip to content

Commit

Permalink
Ensure NEWS entry when tagging
Browse files Browse the repository at this point in the history
  • Loading branch information
nobu committed Feb 3, 2023
1 parent c71ac79 commit 9f6969b
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions rakelib/version.rake
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,27 @@ class << (helper = Bundler::GemHelper.instance)

def version=(v)
unless v == version
news = File.read(File.join(__dir__, "../NEWS.md"))
unless /^## +#{Regexp.quote(version.to_s)} -/ =~ news
abort "Previous version #{version} is not mentioned in NEWS.md"
end
unless already_tagged?
ensure_news("Previous", version)
abort "Previous version #{version} is not tagged yet"
end
end
gemspec.version = v
update_source_version
commit_bump
end

def tag_version
ensure_news("New", version)
super
end

def ensure_news(that, version)
news = File.read(File.join(__dir__, "../NEWS.md"))
unless /^## +#{Regexp.quote(version.to_s)} -/ =~ news
abort "#{that} version #{version} is not mentioned in NEWS.md"
end
end
end

major, minor, teeny = helper.gemspec.version.segments
Expand All @@ -54,5 +63,5 @@ desc "Bump teeny version"
task "bump" => "bump:teeny"

task "tag" do
helper.__send__(:tag_version)
helper.tag_version
end

0 comments on commit 9f6969b

Please sign in to comment.