releasetool 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a6b0bf2084778fb39bcc2e7e1997069473c7fc3d72db0fbd0357e775c6226f29
4
- data.tar.gz: 50c233e3f1efa69f4b027bd214eeebbc4504854706e81b8b3e222e77699ac370
3
+ metadata.gz: e81f8dca8f57336ce42e2af161b9e7fd4815d351bc1b410b169339e3cd8c54d5
4
+ data.tar.gz: 3fe78962d71f7982bf64bd95c0a0591d7cdc379dc3218adb460428fe235327ad
5
5
  SHA512:
6
- metadata.gz: b324b29b9b5ac6f141a0853a8e8887afa788329a9a15dd5dc0030c2d3abab4751f8d67f0fccf5029a2aee56a73aa20c1882ba38fe9cae0fed6d8e0f6399a2fd7
7
- data.tar.gz: 8c6465c57837b267999cd74b71155b7feec58fb6f2508dc7d65a44bd12aeee7d646d723c7d400e068c1a93abee7c9ff1613ac5ee0b871062f7033dcfce713d39
6
+ metadata.gz: 02d46a7f69724be5afc3c2add298fa3a451b83d07dd4a79412324fc63bf7d051d00163a261faa40fd4c52b19b51de33eea8ebf0edbcc203b04377e87e54a8e45
7
+ data.tar.gz: 9d3a23d80627aa7943ed83a7843b22defc817121000a53594d1a4a6fa4651394de2b321652141cddc92d552a850c6a25543c025125ac419444bdd8a9d41306dc
data/.rubocop_todo.yml CHANGED
@@ -38,102 +38,3 @@ Naming/VariableNumber:
38
38
  Style/HashSyntax:
39
39
  Exclude:
40
40
  - 'Rakefile'
41
-
42
- # Offense count: 6
43
- # This cop supports unsafe autocorrection (--autocorrect-all).
44
- # Configuration parameters: EnforcedStyle.
45
- # SupportedStyles: literals, strict
46
- Style/MutableConstant:
47
- Exclude:
48
- - 'lib/releasetool.rb'
49
- - 'lib/releasetool/util.rb'
50
- - 'lib/tasks/release_thor.rb'
51
- - 'spec/fixtures/example_with_releases/config/initializers/00-version.rb'
52
-
53
- # Offense count: 1
54
- # This cop supports unsafe autocorrection (--autocorrect-all).
55
- # Configuration parameters: EnforcedStyle, AllowedMethods, AllowedPatterns.
56
- # SupportedStyles: predicate, comparison
57
- Style/NumericPredicate:
58
- Exclude:
59
- - 'spec/**/*'
60
- - 'lib/tasks/release_thor.rb'
61
-
62
- # Offense count: 2
63
- # This cop supports safe autocorrection (--autocorrect).
64
- # Configuration parameters: PreferredDelimiters.
65
- Style/PercentLiteralDelimiters:
66
- Exclude:
67
- - 'releasetool.gemspec'
68
-
69
- # Offense count: 3
70
- # This cop supports safe autocorrection (--autocorrect).
71
- # Configuration parameters: AllowedCompactTypes.
72
- # SupportedStyles: compact, exploded
73
- Style/RaiseArgs:
74
- EnforcedStyle: compact
75
-
76
- # Offense count: 2
77
- # This cop supports safe autocorrection (--autocorrect).
78
- Style/RedundantPercentQ:
79
- Exclude:
80
- - 'releasetool.gemspec'
81
-
82
- # Offense count: 1
83
- # This cop supports safe autocorrection (--autocorrect).
84
- # Configuration parameters: EnforcedStyle.
85
- # SupportedStyles: only_raise, only_fail, semantic
86
- Style/SignalException:
87
- Exclude:
88
- - 'lib/releasetool/util.rb'
89
-
90
- # Offense count: 1
91
- # This cop supports unsafe autocorrection (--autocorrect-all).
92
- Style/SlicingWithRange:
93
- Exclude:
94
- - 'lib/releasetool/version.rb'
95
-
96
- # Offense count: 1
97
- # This cop supports safe autocorrection (--autocorrect).
98
- # Configuration parameters: AllowModifier.
99
- Style/SoleNestedConditional:
100
- Exclude:
101
- - 'lib/releasetool/release.rb'
102
-
103
- # Offense count: 1
104
- # This cop supports unsafe autocorrection (--autocorrect-all).
105
- # Configuration parameters: RequireEnglish, EnforcedStyle.
106
- # SupportedStyles: use_perl_names, use_english_names, use_builtin_english_names
107
- Style/SpecialGlobalVars:
108
- Exclude:
109
- - 'releasetool.gemspec'
110
-
111
- # Offense count: 34
112
- # This cop supports safe autocorrection (--autocorrect).
113
- # Configuration parameters: EnforcedStyle, ConsistentQuotesInMultiline.
114
- # SupportedStyles: single_quotes, double_quotes
115
- Style/StringLiterals:
116
- Exclude:
117
- - 'Gemfile'
118
- - 'bin/release'
119
- - 'lib/releasetool/release.rb'
120
- - 'lib/releasetool/util.rb'
121
- - 'lib/tasks/release_thor.rb'
122
- - 'releasetool.gemspec'
123
- - 'spec/releasetool_spec.rb'
124
- - 'spec/spec_helper.rb'
125
- - 'spec/version_spec.rb'
126
-
127
- # Offense count: 1
128
- # This cop supports safe autocorrection (--autocorrect).
129
- # Configuration parameters: EnforcedStyle.
130
- # SupportedStyles: single_quotes, double_quotes
131
- Style/StringLiteralsInInterpolation:
132
- Exclude:
133
- - 'lib/tasks/release_thor.rb'
134
-
135
- # Offense count: 1
136
- # This cop supports unsafe autocorrection (--autocorrect-all).
137
- Style/ZeroLengthPredicate:
138
- Exclude:
139
- - 'lib/tasks/release_thor.rb'
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
3
+ source "https://rubygems.org"
4
4
 
5
5
  # Specify your gem's dependencies in releasetool.gemspec
6
6
  gemspec
data/bin/release CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- $LOAD_PATH << File.expand_path('../lib', File.dirname(__FILE__))
5
- require File.expand_path('../lib/tasks/release_thor.rb', File.dirname(__FILE__))
4
+ $LOAD_PATH << File.expand_path("../lib", File.dirname(__FILE__))
5
+ require File.expand_path("../lib/tasks/release_thor.rb", File.dirname(__FILE__))
6
6
 
7
7
  Release.start
@@ -8,13 +8,5 @@ module Releasetool
8
8
  def initialize(config)
9
9
  @config = config
10
10
  end
11
-
12
- def after_prepare(version)
13
- # noop
14
- end
15
-
16
- def after_commit(version)
17
- # noop
18
- end
19
11
  end
20
12
  end
@@ -5,16 +5,23 @@ require "pathname"
5
5
 
6
6
  module Releasetool
7
7
  class Configuration
8
- def after_start_hook(version)
9
- return nil unless hooks.respond_to?(:after_start)
8
+ BEFORE_AFTER = %i[before after].freeze
9
+ EVENTS = %i[start commit].freeze
10
10
 
11
- hooks.after_start(version)
11
+ def around_hooks(event, version)
12
+ run_hook_for(:before, event, version)
13
+ yield
14
+ run_hook_for(:after, event, version)
12
15
  end
13
16
 
14
- def after_commit_hook(version)
15
- return nil unless hooks.respond_to?(:after_commit)
17
+ def run_hook_for(before_after, event, version)
18
+ raise "before_after must be in #{BEFORE_AFTER.inspect}" unless BEFORE_AFTER.include?(before_after)
19
+ raise "event must be in #{EVENTS.inspect}" unless EVENTS.include?(event)
16
20
 
17
- hooks.after_commit(version)
21
+ hook = :"#{before_after}_#{event}"
22
+ return nil unless hooks.respond_to?(hook)
23
+
24
+ hooks.public_send(hook, version)
18
25
  end
19
26
 
20
27
  def generate
@@ -61,10 +68,18 @@ module Releasetool
61
68
  class Hooks < Releasetool::BaseHooks
62
69
  include Releasetool::Util
63
70
 
71
+ # def before_start(version)
72
+ # puts "before_start has been called"
73
+ # end
74
+
64
75
  # def after_start(version)
65
76
  # puts "after_start has been called"
66
77
  # end
67
78
 
79
+ # def before_commit(version)
80
+ # puts "before_commit has been called"
81
+ # end
82
+
68
83
  # def after_commit(version)
69
84
  # puts "after_commit has been called"
70
85
  # end
@@ -10,9 +10,8 @@ module Releasetool
10
10
  def initialize(version, previous:)
11
11
  raise "Version must be a Releasetool::Version" unless version.is_a?(Releasetool::Version)
12
12
 
13
- if previous
14
- raise "Previous must be nil or a Releasetool::Version" unless version.is_a?(Releasetool::Version)
15
- end
13
+ raise "Previous must be nil or a Releasetool::Version" if previous && !previous.is_a?(Releasetool::Version)
14
+
16
15
  @version = version
17
16
  @previous = previous
18
17
  end
@@ -26,13 +25,13 @@ module Releasetool
26
25
  puts "-" * 80
27
26
  puts " File '#{notes_file}' already exists (appending)"
28
27
  puts "-" * 80
29
- File.open(notes_file, 'a') do |f|
28
+ File.open(notes_file, "a") do |f|
30
29
  f.puts("\n\nAPPENDED:\n\n")
31
30
  f.puts(notes)
32
31
  end
33
32
  else
34
33
  ensure_dir
35
- File.open(notes_file, 'w') do |f|
34
+ File.open(notes_file, "w") do |f|
36
35
  f.puts(headers)
37
36
  f.puts(notes)
38
37
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'English'
3
+ require "English"
4
4
  require "releasetool/configuration"
5
5
 
6
6
  module Releasetool
@@ -11,11 +11,11 @@ module Releasetool
11
11
 
12
12
  def self.version_file
13
13
  # rails out of box
14
- ENV['RELEASETOOL_VERSION_FILE'] || "config/initializers/00-version.rb"
14
+ ENV["RELEASETOOL_VERSION_FILE"] || "config/initializers/00-version.rb"
15
15
  end
16
16
 
17
17
  def stored_version
18
- fail Thor::Error.new("No stored version... did you forget to do release start?") unless File.exist?(RELEASE_MARKER_FILE)
18
+ raise Thor::Error, "No stored version... did you forget to do release start?" unless File.exist?(RELEASE_MARKER_FILE)
19
19
 
20
20
  File.read(RELEASE_MARKER_FILE).strip
21
21
  end
@@ -26,13 +26,13 @@ module Releasetool
26
26
 
27
27
  def guarded_system(command)
28
28
  puts command
29
- system(command) or raise Thor::Error.new("Couldn't '#{command}'")
29
+ system(command) or raise(Thor::Error, "Couldn't '#{command}'")
30
30
  end
31
31
 
32
32
  def guarded_capture(command)
33
33
  puts command
34
34
  output = `#{command}`
35
- raise Thor::Error.new("Couldn't '#{command}'") unless $CHILD_STATUS
35
+ raise Thor::Error, "Couldn't '#{command}'" unless $CHILD_STATUS
36
36
 
37
37
  output
38
38
  end
@@ -32,7 +32,7 @@ module Releasetool
32
32
 
33
33
  def to_s_without_v
34
34
  if @ident[0] == "v"
35
- @ident[1..-1]
35
+ @ident[1..]
36
36
  else
37
37
  @ident
38
38
  end
data/lib/releasetool.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  require "releasetool/release"
4
4
 
5
5
  module Releasetool
6
- VERSION = "0.5.3"
6
+ VERSION = "0.6.0"
7
7
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'thor'
3
+ require "thor"
4
4
  require "releasetool"
5
5
  require "releasetool/release"
6
6
  require "releasetool/util"
@@ -9,6 +9,7 @@ require "shellwords"
9
9
 
10
10
  class Release < Thor
11
11
  include Releasetool::Util
12
+
12
13
  desc "init", <<-END
13
14
  generate optional config directory and optional hooks file
14
15
  END
@@ -44,15 +45,15 @@ class Release < Thor
44
45
  END
45
46
 
46
47
  def log(*args)
47
- extra = " #{args.join(" ")}" if args.length > 0
48
+ extra = " #{args.join(' ')}" if args.length.positive?
48
49
  guarded_system("git log #{previous_version}..#{extra}")
49
50
  end
50
51
 
51
52
  # ========================
52
53
 
53
54
  method_option :since, type: :string, desc: "since commit_ref (or will use most recent tag)", required: false,
54
- aliases: 's'
55
- method_option :edit, type: :boolean, desc: "edit", required: false, aliases: 'e'
55
+ aliases: "s"
56
+ method_option :edit, type: :boolean, desc: "edit", required: false, aliases: "e"
56
57
  method_option :minor, type: :boolean, desc: "minor version", required: false, default: false
57
58
 
58
59
  desc "start (NEW_VERSION)", <<-END
@@ -60,30 +61,37 @@ class Release < Thor
60
61
  END
61
62
 
62
63
  def start(specified_version = nil)
63
- raise Thor::Error.new("Can't start when already started on a version. release abort or release finish") if File.exist?(RELEASE_MARKER_FILE)
64
+ raise Thor::Error, "Can't start when already started on a version. release abort or release finish" if File.exist?(RELEASE_MARKER_FILE)
64
65
 
65
66
  version = specified_version ? Releasetool::Version.new(specified_version) : next_version
66
- File.write(RELEASE_MARKER_FILE, version)
67
- Releasetool::Release.new(version, previous: previous_version).prepare(edit: options[:edit])
68
- config.after_start_hook(version)
67
+ config.around_hooks(:start, version) do
68
+ File.write(RELEASE_MARKER_FILE, version)
69
+ Releasetool::Release.new(version, previous: previous_version).prepare(edit: options[:edit])
70
+ end
69
71
  end
70
72
 
71
- DEFAULT_COMMIT_MESSAGE = 'preparing for release [CI SKIP]'
73
+ DEFAULT_COMMIT_MESSAGE = "preparing for release [CI SKIP]"
72
74
  desc "commit (NEW_VERSION)", <<-END
73
75
  Commit release and version identifier to git with message '#{DEFAULT_COMMIT_MESSAGE}'.
74
76
  If no version given, it will use the version stored by release start
75
77
  END
76
78
 
77
- method_option :edit, type: :boolean, desc: "release commit --edit allows you to edit, or --no-edit (default) which allows you to just skip", aliases: 'e', default: false
79
+ method_option :edit, type: :boolean, desc: "release commit --edit allows you to edit, or --no-edit (default) which allows you to just skip", aliases: "e", default: false
78
80
  method_option :after, type: :boolean, desc: " --after (only do after -- needed for when after fails first time); --no-after (only do the standard); default is do both", default: "default", check_default_type: false
81
+
79
82
  def commit(version = nil)
80
83
  version ||= stored_version
81
84
  if options[:after] == "default" || !options[:after]
85
+ config.run_hook_for(:before, :commit, version)
82
86
  guarded_system("git add #{DIR}")
83
87
  guarded_system("git add #{Releasetool::Util.version_file}") if File.exist?(Releasetool::Util.version_file)
84
- guarded_system("git commit #{DIR} #{File.exist?(Releasetool::Util.version_file) ? Releasetool::Util.version_file : ''} #{options[:edit] ? '-e' : nil} -m\"#{DEFAULT_COMMIT_MESSAGE}\"")
88
+ args = ["git", "commit", DIR]
89
+ args << Releasetool::Util.version_file if File.exist?(Releasetool::Util.version_file)
90
+ args << "-e" if options[:edit]
91
+ args << "-m" << DEFAULT_COMMIT_MESSAGE
92
+ guarded_system(Shellwords.join(args))
85
93
  end
86
- config.after_commit_hook(version) if options[:after]
94
+ config.run_hook_for(:after, :commit, version) if options[:after]
87
95
  end
88
96
 
89
97
  desc "tag (NEW_VERSION)", <<-END
@@ -120,6 +128,7 @@ class Release < Thor
120
128
  map %w[--version -v] => :__print_version
121
129
 
122
130
  desc "--version, -v", "print the version"
131
+
123
132
  def __print_version
124
133
  say "Releasetool v#{Releasetool::VERSION}"
125
134
  end
@@ -0,0 +1,6 @@
1
+ v0.6.0 Release Notes
2
+
3
+ *Changes since v0.5.3*
4
+
5
+ - allow for before_start and before_commit hooks (#19)
6
+ - update rubocop and perform fixes (#18)
data/releasetool.gemspec CHANGED
@@ -1,30 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- lib = File.expand_path('lib', __dir__)
3
+ require "English"
4
+ lib = File.expand_path("lib", __dir__)
4
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'releasetool'
6
+ require "releasetool"
6
7
 
7
8
  Gem::Specification.new do |spec|
8
9
  spec.name = "releasetool"
9
10
  spec.version = Releasetool::VERSION
10
11
  spec.authors = ["Tim Diggins"]
11
12
  spec.email = ["tim@red56.co.uk"]
12
- spec.description = %q{Some release-related functions, initially just release notes management and creation}
13
- spec.summary = %q{Release management tools}
13
+ spec.description = "Some release-related functions, initially just release notes management and creation"
14
+ spec.summary = "Release management tools"
14
15
  spec.homepage = ""
15
16
  spec.license = "MIT"
16
17
 
17
- spec.files = `git ls-files`.split($/)
18
+ spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
18
19
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
20
  spec.require_paths = ["lib"]
20
- spec.required_ruby_version = '>= 2.7.0'
21
+ spec.required_ruby_version = ">= 2.7.0"
21
22
 
22
- spec.add_dependency 'thor', '>= 0.18'
23
+ spec.add_dependency "thor", ">= 0.18"
23
24
 
24
25
  spec.add_development_dependency "bundler", "~> 2.1"
25
26
  spec.add_development_dependency "climate_control"
26
27
  spec.add_development_dependency "rake"
27
28
  spec.add_development_dependency "rspec"
28
- spec.add_development_dependency "rubocop", "1.56.3"
29
- spec.metadata['rubygems_mfa_required'] = 'true'
29
+ spec.add_development_dependency "rubocop", "1.84.2"
30
+ spec.metadata["rubygems_mfa_required"] = "true"
30
31
  end
@@ -7,10 +7,18 @@ module Releasetool
7
7
  class Hooks < Releasetool::BaseHooks
8
8
  include Releasetool::Util
9
9
 
10
+ def before_start(version)
11
+ puts "before_start(#{version}) has been called"
12
+ end
13
+
10
14
  def after_start(version)
11
15
  puts "after_start(#{version}) has been called"
12
16
  end
13
17
 
18
+ def before_commit(version)
19
+ puts "before_commit(#{version}) has been called"
20
+ end
21
+
14
22
  def after_commit(version)
15
23
  puts "after_commit(#{version}) has been called"
16
24
  end
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
4
- require 'fileutils'
5
- require 'climate_control'
6
- require File.expand_path('../lib/tasks/release_thor', __dir__)
3
+ require "spec_helper"
4
+ require "fileutils"
5
+ require "climate_control"
6
+ require File.expand_path("../lib/tasks/release_thor", __dir__)
7
7
 
8
8
  RSpec.describe Releasetool do
9
- it 'should have a version number' do
9
+ it "should have a version number" do
10
10
  expect(Releasetool::VERSION).not_to be_nil
11
11
  end
12
12
  end
@@ -20,16 +20,16 @@ RSpec.describe Release, quietly: true do
20
20
 
21
21
  subject { Release.new }
22
22
 
23
- let(:tmpdir) { File.expand_path('../tmp/testing', __dir__) }
24
- let(:root_dir) { File.expand_path('..', __dir__) }
25
- let(:hooks_example_rb) { File.expand_path('./fixtures/hooks_example.rb', __dir__) }
26
- let(:empty_file) { File.expand_path('./fixtures/empty_file.rb', __dir__) }
23
+ let(:tmpdir) { File.expand_path("../tmp/testing", __dir__) }
24
+ let(:root_dir) { File.expand_path("..", __dir__) }
25
+ let(:hooks_example_rb) { File.expand_path("./fixtures/hooks_example.rb", __dir__) }
26
+ let(:empty_file) { File.expand_path("./fixtures/empty_file.rb", __dir__) }
27
27
  before {
28
28
  Releasetool.send(:remove_const, :Hooks) if defined?(Releasetool::Hooks)
29
29
  FileUtils.rmtree(tmpdir)
30
30
  FileUtils.mkdir_p(tmpdir)
31
31
  FileUtils.chdir(tmpdir)
32
- system('tar -xf ../../spec/fixtures/example_with_releases.tar')
32
+ system("tar -xf ../../spec/fixtures/example_with_releases.tar")
33
33
  }
34
34
  after {
35
35
  FileUtils.chdir(root_dir)
@@ -47,24 +47,24 @@ RSpec.describe Release, quietly: true do
47
47
 
48
48
  describe "start" do
49
49
  context "with a since" do
50
- subject { Release.new([], { since: 'v0.0.2' }, {}) }
50
+ subject { Release.new([], { since: "v0.0.2" }, {}) }
51
51
  it "it should do a prepare and store a file" do
52
52
  expect(Releasetool::Release).to receive(:new).with(v_0_0_3, previous: v_0_0_2).and_return(mock_target)
53
53
  expect(mock_target).to receive(:prepare)
54
- subject.start('v0.0.3')
54
+ subject.start("v0.0.3")
55
55
  end
56
56
  it "stores a release-version file" do
57
57
  allow(Releasetool::Release).to receive(:new).with(v_0_0_3, previous: v_0_0_2).and_return(mock_target)
58
58
  allow(mock_target).to receive(:prepare)
59
- expect { subject.start('v0.0.3') }.to change {
60
- File.exist?(File.join(tmpdir, '.RELEASE_NEW_VERSION'))
59
+ expect { subject.start("v0.0.3") }.to change {
60
+ File.exist?(File.join(tmpdir, ".RELEASE_NEW_VERSION"))
61
61
  }
62
- expect(File.read(File.join(tmpdir, '.RELEASE_NEW_VERSION')).to_s).to eq('v0.0.3')
62
+ expect(File.read(File.join(tmpdir, ".RELEASE_NEW_VERSION")).to_s).to eq("v0.0.3")
63
63
  end
64
64
 
65
65
  it "with existing release-version file, it should freak out" do
66
- FileUtils.touch(File.join(tmpdir, '.RELEASE_NEW_VERSION'))
67
- expect { subject.start('v0.0.3') }.to raise_error(/Can't start when already started on a version/)
66
+ FileUtils.touch(File.join(tmpdir, ".RELEASE_NEW_VERSION"))
67
+ expect { subject.start("v0.0.3") }.to raise_error(/Can't start when already started on a version/)
68
68
  end
69
69
  end
70
70
 
@@ -72,7 +72,7 @@ RSpec.describe Release, quietly: true do
72
72
  it "it should use latest tag" do
73
73
  expect(Releasetool::Release).to receive(:new).with(v_0_0_3, previous: v_0_0_1).and_return(mock_target)
74
74
  expect(mock_target).to receive(:prepare)
75
- subject.start('v0.0.3')
75
+ subject.start("v0.0.3")
76
76
  end
77
77
  end
78
78
 
@@ -123,8 +123,12 @@ RSpec.describe Release, quietly: true do
123
123
  FileUtils.cp(hooks_example_rb, "#{tmpdir}/config/releasetool/hooks.rb")
124
124
  end
125
125
  it "should output hook" do
126
- expected = "after_start(v0.0.2) has been called"
127
- expect { subject.start }.to output(/#{Regexp.escape(expected)}/).to_stdout
126
+ outputs = [
127
+ "before_start(v0.0.2) has been called",
128
+ "after_start(v0.0.2) has been called"
129
+ ]
130
+ expected_output = /#{outputs.map { |output| Regexp.escape(output) }.join('.*')}/m
131
+ expect { subject.start }.to output(expected_output).to_stdout
128
132
  end
129
133
  end
130
134
  end
@@ -132,16 +136,17 @@ RSpec.describe Release, quietly: true do
132
136
 
133
137
  describe "commit" do
134
138
  let(:options) { { after: "default" } }
139
+ let(:default_commit_message_escaped) { 'preparing\ for\ release\ \[CI\ SKIP\]' }
135
140
  subject { Release.new([], options, {}) }
136
141
 
137
142
  let!(:commit_expectations) {
138
143
  expect(subject).to receive(:guarded_system).with("git add release_notes")
139
144
  expect(subject).to receive(:guarded_system).with("git add config/initializers/00-version.rb")
140
- expect(subject).to receive(:guarded_system).with("git commit release_notes config/initializers/00-version.rb -m\"#{Release::DEFAULT_COMMIT_MESSAGE}\"")
145
+ expect(subject).to receive(:guarded_system).with("git commit release_notes config/initializers/00-version.rb -m #{default_commit_message_escaped}")
141
146
  }
142
147
  context "with no args" do
143
148
  it "outputs without -e" do
144
- subject.commit('v0.0.3')
149
+ subject.commit("v0.0.3")
145
150
  end
146
151
  end
147
152
 
@@ -151,10 +156,10 @@ RSpec.describe Release, quietly: true do
151
156
  let!(:commit_expectations) {
152
157
  expect(subject).to receive(:guarded_system).with("git add release_notes")
153
158
  expect(subject).to receive(:guarded_system).with("git add config/initializers/00-version.rb")
154
- expect(subject).to receive(:guarded_system).with("git commit release_notes config/initializers/00-version.rb -e -m\"#{Release::DEFAULT_COMMIT_MESSAGE}\"")
159
+ expect(subject).to receive(:guarded_system).with("git commit release_notes config/initializers/00-version.rb -e -m #{default_commit_message_escaped}")
155
160
  }
156
161
  it "outputs with e" do
157
- subject.commit('v0.0.3')
162
+ subject.commit("v0.0.3")
158
163
  end
159
164
  end
160
165
 
@@ -162,7 +167,7 @@ RSpec.describe Release, quietly: true do
162
167
  it "should generate and still work" do
163
168
  subject.init
164
169
  expected = "after_commit(v0.0.3) has been called"
165
- expect { subject.commit('v0.0.3') }.not_to output(/#{Regexp.escape(expected)}/).to_stdout
170
+ expect { subject.commit("v0.0.3") }.not_to output(/#{Regexp.escape(expected)}/).to_stdout
166
171
  end
167
172
  end
168
173
 
@@ -172,8 +177,12 @@ RSpec.describe Release, quietly: true do
172
177
  FileUtils.cp(hooks_example_rb, "#{tmpdir}/config/releasetool/hooks.rb")
173
178
  end
174
179
  it "should output hook" do
175
- expected = "after_commit(v0.0.3) has been called"
176
- expect { subject.commit('v0.0.3') }.to output(/#{Regexp.escape(expected)}/).to_stdout
180
+ outputs = [
181
+ "before_commit(v0.0.3) has been called",
182
+ "after_commit(v0.0.3) has been called"
183
+ ]
184
+ expected_output = /#{outputs.map { |output| Regexp.escape(output) }.join('.*')}/m
185
+ expect { subject.commit("v0.0.3") }.to output(expected_output).to_stdout
177
186
  end
178
187
  context "with --after" do
179
188
  let(:options) { { after: true } }
@@ -182,14 +191,14 @@ RSpec.describe Release, quietly: true do
182
191
  }
183
192
  it "should output hook only" do
184
193
  expected = "after_commit(v0.0.3) has been called"
185
- expect { subject.commit('v0.0.3') }.to output(/#{Regexp.escape(expected)}/).to_stdout
194
+ expect { subject.commit("v0.0.3") }.to output(/#{Regexp.escape(expected)}/).to_stdout
186
195
  end
187
196
  end
188
197
  context "with --no-after" do
189
198
  let(:options) { { after: false } }
190
199
  it "shouldn't output hook" do
191
200
  expected = "after_commit(v0.0.3) has been called"
192
- expect { subject.commit('v0.0.3') }.not_to output(/#{Regexp.escape(expected)}/).to_stdout
201
+ expect { subject.commit("v0.0.3") }.not_to output(/#{Regexp.escape(expected)}/).to_stdout
193
202
  end
194
203
  end
195
204
  end
data/spec/spec_helper.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- $LOAD_PATH.unshift File.expand_path('../lib', __dir__)
4
- require 'releasetool'
3
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
4
+ require "releasetool"
5
5
 
6
6
  RSpec.configure do |config|
7
7
  config.around quietly: true do |example|
data/spec/version_spec.rb CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'spec_helper'
3
+ require "spec_helper"
4
4
 
5
5
  require "releasetool/version"
6
6
  describe Releasetool::Version do
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releasetool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Diggins
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2024-06-24 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: thor
@@ -86,14 +85,14 @@ dependencies:
86
85
  requirements:
87
86
  - - '='
88
87
  - !ruby/object:Gem::Version
89
- version: 1.56.3
88
+ version: 1.84.2
90
89
  type: :development
91
90
  prerelease: false
92
91
  version_requirements: !ruby/object:Gem::Requirement
93
92
  requirements:
94
93
  - - '='
95
94
  - !ruby/object:Gem::Version
96
- version: 1.56.3
95
+ version: 1.84.2
97
96
  description: Some release-related functions, initially just release notes management
98
97
  and creation
99
98
  email:
@@ -131,6 +130,7 @@ files:
131
130
  - release_notes/v0.5.1.md
132
131
  - release_notes/v0.5.2.md
133
132
  - release_notes/v0.5.3.md
133
+ - release_notes/v0.6.0.md
134
134
  - releasetool.gemspec
135
135
  - spec/fixtures/empty_file.rb
136
136
  - spec/fixtures/example_with_releases.tar
@@ -143,7 +143,6 @@ licenses:
143
143
  - MIT
144
144
  metadata:
145
145
  rubygems_mfa_required: 'true'
146
- post_install_message:
147
146
  rdoc_options: []
148
147
  require_paths:
149
148
  - lib
@@ -158,8 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
158
157
  - !ruby/object:Gem::Version
159
158
  version: '0'
160
159
  requirements: []
161
- rubygems_version: 3.5.13
162
- signing_key:
160
+ rubygems_version: 4.0.6
163
161
  specification_version: 4
164
162
  summary: Release management tools
165
163
  test_files: []