diff --git a/History.md b/History.md index c8b41d6..b124c31 100644 --- a/History.md +++ b/History.md @@ -22,6 +22,8 @@ Changes: after 0.9.0, where before it was the last tag by name. * `-p` (`--point`) now splits commit messages into points and the default doesn't; the two were the wrong way round. +* `vclog-bump` gives the next patch version when nothing has changed + since the last release, where before it failed. * Find the history file whatever its case (`History.md`, `HISTORY.md`). * Find a project's config file (`etc/vclog.rb`, `config/vclog.rb`, `.vclog`, ...), which the last code on master failed to do. diff --git a/lib/vclog/repo.rb b/lib/vclog/repo.rb index 6e41ddb..e3a2772 100644 --- a/lib/vclog/repo.rb +++ b/lib/vclog/repo.rb @@ -208,8 +208,10 @@ def report(options) # def bump last_release = releases(changes).first - max = last_release.changes.map{ |c| c.level }.max - if max > 1 + max = last_release.changes.map{ |c| c.level }.compact.max + if max.nil? + bump_part('patch') # nothing has changed since the last release + elsif max > 1 bump_part('major') elsif max >= 0 bump_part('minor') diff --git a/test/case_git.rb b/test/case_git.rb index d351a8b..dd2ed01 100644 --- a/test/case_git.rb +++ b/test/case_git.rb @@ -67,4 +67,17 @@ @repo.bump_part('patch').assert == "0.10.1" end + test "bump is a patch when nothing has changed since the last release" do + Dir.mktmpdir do |dir| + env = {'GIT_CONFIG_GLOBAL'=>File::NULL, 'GIT_CONFIG_SYSTEM'=>File::NULL} + [ %w[init -q -b master], %w[config user.name Tester], %w[config user.email tester@example.com], + %w[config commit.gpgsign false], %w[config tag.gpgsign false], + ['commit', '-q', '--allow-empty', '-m', 'Start.'], %w[tag -a -m First 1.2.3] + ].each do |args| + system(env, 'git', '-C', dir, *args, :out=>File::NULL, :err=>File::NULL).assert == true + end + VCLog::Repo.new(dir, {}).bump.assert == "1.2.4" + end + end + end