create_github_release 1.0.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +4 -1
  3. data/.solargraph.yml +23 -0
  4. data/.vscode/launch.json +19 -0
  5. data/.yardopts +1 -0
  6. data/CHANGELOG.md +26 -0
  7. data/README.md +165 -47
  8. data/Rakefile +7 -4
  9. data/create_github_release.gemspec +7 -4
  10. data/exe/create-github-release +5 -1
  11. data/lib/create_github_release/assertion_base.rb +0 -2
  12. data/lib/create_github_release/assertions/bundle_is_up_to_date.rb +1 -1
  13. data/lib/create_github_release/assertions/gh_authenticated.rb +1 -1
  14. data/lib/create_github_release/assertions/gh_command_exists.rb +1 -1
  15. data/lib/create_github_release/assertions/git_command_exists.rb +1 -1
  16. data/lib/create_github_release/assertions/in_git_repo.rb +1 -1
  17. data/lib/create_github_release/assertions/in_repo_root_directory.rb +1 -1
  18. data/lib/create_github_release/assertions/local_and_remote_on_same_commit.rb +1 -1
  19. data/lib/create_github_release/assertions/local_release_branch_does_not_exist.rb +1 -1
  20. data/lib/create_github_release/assertions/no_staged_changes.rb +1 -1
  21. data/lib/create_github_release/assertions/no_uncommitted_changes.rb +1 -1
  22. data/lib/create_github_release/assertions/on_default_branch.rb +1 -1
  23. data/lib/create_github_release/assertions/remote_release_branch_does_not_exist.rb +1 -1
  24. data/lib/create_github_release/assertions/remote_release_tag_does_not_exist.rb +1 -1
  25. data/lib/create_github_release/command_line/options.rb +151 -0
  26. data/lib/create_github_release/command_line/parser.rb +253 -0
  27. data/lib/create_github_release/command_line/validations.rb +293 -0
  28. data/lib/create_github_release/command_line/validator.rb +93 -0
  29. data/lib/create_github_release/command_line.rb +43 -0
  30. data/lib/create_github_release/project.rb +136 -76
  31. data/lib/create_github_release/release_assertions.rb +2 -1
  32. data/lib/create_github_release/release_tasks.rb +2 -1
  33. data/lib/create_github_release/tasks/commit_release.rb +1 -1
  34. data/lib/create_github_release/tasks/create_github_release.rb +1 -1
  35. data/lib/create_github_release/tasks/create_release_branch.rb +1 -1
  36. data/lib/create_github_release/tasks/create_release_pull_request.rb +1 -1
  37. data/lib/create_github_release/tasks/create_release_tag.rb +1 -1
  38. data/lib/create_github_release/tasks/push_release.rb +1 -1
  39. data/lib/create_github_release/tasks/update_changelog.rb +1 -1
  40. data/lib/create_github_release/tasks/update_version.rb +13 -14
  41. data/lib/create_github_release/version.rb +1 -1
  42. data/lib/create_github_release.rb +1 -2
  43. metadata +31 -25
  44. data/lib/create_github_release/command_line_options.rb +0 -367
  45. data/lib/create_github_release/command_line_parser.rb +0 -225
@@ -15,7 +15,7 @@ module CreateGithubRelease
15
15
  # @example
16
16
  # require 'create_github_release'
17
17
  #
18
- # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
18
+ # options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
19
19
  # project = CreateGithubRelease::Project.new(options)
20
20
  # task = CreateGithubRelease::Tasks::CreateReleaseTag.new(project)
21
21
  # begin
@@ -15,7 +15,7 @@ module CreateGithubRelease
15
15
  # @example
16
16
  # require 'create_github_release'
17
17
  #
18
- # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
18
+ # options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
19
19
  # project = CreateGithubRelease::Project.new(options)
20
20
  # task = CreateGithubRelease::Tasks::PushRelease.new(project)
21
21
  # begin
@@ -19,7 +19,7 @@ module CreateGithubRelease
19
19
  # @example
20
20
  # require 'create_github_release'
21
21
  #
22
- # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
22
+ # options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
23
23
  # project = CreateGithubRelease::Project.new(options)
24
24
  # task = CreateGithubRelease::Tasks::UpdateChangelog.new(project)
25
25
  # begin
@@ -5,17 +5,17 @@ require 'create_github_release/task_base'
5
5
 
6
6
  module CreateGithubRelease
7
7
  module Tasks
8
- # Update the gem version using Bump
8
+ # Update the gem version using semverify
9
9
  #
10
10
  # @api public
11
11
  #
12
12
  class UpdateVersion < TaskBase
13
- # Update the gem version using Bump
13
+ # Update the gem version using semverify
14
14
  #
15
15
  # @example
16
16
  # require 'create_github_release'
17
17
  #
18
- # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
18
+ # options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
19
19
  # project = CreateGithubRelease::Project.new(options)
20
20
  # task = CreateGithubRelease::Tasks::UpdateVersion.new(project)
21
21
  # begin
@@ -33,35 +33,34 @@ module CreateGithubRelease
33
33
  return if project.first_release?
34
34
 
35
35
  print 'Updating version...'
36
- bump_version
36
+ increment_version
37
37
  stage_version_file
38
38
  end
39
39
 
40
40
  private
41
41
 
42
- # Update the version using bump
42
+ # Increment the version using semverify
43
43
  # @return [void]
44
44
  # @api private
45
- def bump_version
46
- `bump #{project.release_type} --no-commit`
47
- error 'Could not bump version' unless $CHILD_STATUS.success?
45
+ def increment_version
46
+ `semverify next-#{project.release_type}`
47
+ error 'Could not increment version' unless $CHILD_STATUS.success?
48
48
  end
49
49
 
50
- # Return the path the the version file using bump
50
+ # Return the path the the version file using semverify
51
51
  # @return [String]
52
52
  # @api private
53
- def bump_version_file
54
- output = `bump file`
55
- error 'Bump could determine the version file' unless $CHILD_STATUS.success?
53
+ def version_file
54
+ output = `semverify file`
55
+ error 'Semverify could determine the version file' unless $CHILD_STATUS.success?
56
56
 
57
57
  output.lines.last.chomp
58
58
  end
59
59
 
60
- # Identify the version file using bump and stage the change to it
60
+ # Identify the version file using semverify and stage the change to it
61
61
  # @return [void]
62
62
  # @api private
63
63
  def stage_version_file
64
- version_file = bump_version_file
65
64
  `git add "#{version_file}"`
66
65
  if $CHILD_STATUS.success?
67
66
  puts 'OK'
@@ -2,5 +2,5 @@
2
2
 
3
3
  module CreateGithubRelease
4
4
  # The version of this gem
5
- VERSION = '1.0.0'
5
+ VERSION = '1.2.0'
6
6
  end
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'create_github_release/backtick_debug'
4
- require 'create_github_release/command_line_options'
5
- require 'create_github_release/command_line_parser'
4
+ require 'create_github_release/command_line'
6
5
  require 'create_github_release/project'
7
6
 
8
7
  require 'create_github_release/change'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: create_github_release
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-05 00:00:00.000000000 Z
11
+ date: 2024-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bump
14
+ name: semverify
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.10'
20
- type: :development
19
+ version: '0.3'
20
+ type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.10'
26
+ version: '0.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler-audit
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.9'
41
+ - !ruby/object:Gem::Dependency
42
+ name: debug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rake
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +136,6 @@ dependencies:
122
136
  - - "~>"
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0.8'
125
- - !ruby/object:Gem::Dependency
126
- name: solargraph
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '0.47'
132
- type: :development
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '0.47'
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: timecop
141
141
  requirement: !ruby/object:Gem::Requirement
@@ -191,6 +191,8 @@ files:
191
191
  - ".markdownlint.yml"
192
192
  - ".rspec"
193
193
  - ".rubocop.yml"
194
+ - ".solargraph.yml"
195
+ - ".vscode/launch.json"
194
196
  - ".yardopts"
195
197
  - CHANGELOG.md
196
198
  - Gemfile
@@ -220,8 +222,11 @@ files:
220
222
  - lib/create_github_release/backtick_debug.rb
221
223
  - lib/create_github_release/change.rb
222
224
  - lib/create_github_release/changelog.rb
223
- - lib/create_github_release/command_line_options.rb
224
- - lib/create_github_release/command_line_parser.rb
225
+ - lib/create_github_release/command_line.rb
226
+ - lib/create_github_release/command_line/options.rb
227
+ - lib/create_github_release/command_line/parser.rb
228
+ - lib/create_github_release/command_line/validations.rb
229
+ - lib/create_github_release/command_line/validator.rb
225
230
  - lib/create_github_release/project.rb
226
231
  - lib/create_github_release/release_assertions.rb
227
232
  - lib/create_github_release/release_tasks.rb
@@ -243,7 +248,8 @@ metadata:
243
248
  allowed_push_host: https://rubygems.org
244
249
  homepage_uri: https://github.com/main-branch/create_github_release
245
250
  source_code_uri: https://github.com/main-branch/create_github_release
246
- changelog_uri: https://github.com/main-branch/create_github_release
251
+ changelog_uri: https://rubydoc.info/gems/create_github_release/1.2.0/file/CHANGELOG.md
252
+ documentation_uri: https://rubydoc.info/gems/create_github_release/1.2.0
247
253
  rubygems_mfa_required: 'true'
248
254
  post_install_message:
249
255
  rdoc_options: []
@@ -253,14 +259,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
253
259
  requirements:
254
260
  - - ">="
255
261
  - !ruby/object:Gem::Version
256
- version: 2.7.0
262
+ version: 3.0.0
257
263
  required_rubygems_version: !ruby/object:Gem::Requirement
258
264
  requirements:
259
265
  - - ">="
260
266
  - !ruby/object:Gem::Version
261
267
  version: '0'
262
268
  requirements: []
263
- rubygems_version: 3.4.1
269
+ rubygems_version: 3.5.3
264
270
  signing_key:
265
271
  specification_version: 4
266
272
  summary: A script to create a GitHub release for a Ruby Gem
@@ -1,367 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'uri'
4
-
5
- # rubocop:disable Metrics/ModuleLength
6
-
7
- module CreateGithubRelease
8
- # An array of the valid release types
9
- # @return [Array<String>]
10
- # @api private
11
- VALID_RELEASE_TYPES = %w[major minor patch first].freeze
12
-
13
- # Regex pattern for a [valid git reference](https://git-scm.com/docs/git-check-ref-format)
14
- # @return [Regexp]
15
- # @api private
16
- VALID_REF_PATTERN = /^(?:(?:[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*)|(?:[a-zA-Z0-9-]+))$/.freeze
17
-
18
- # rubocop:disable Metrics/ClassLength
19
-
20
- # Stores and validates the command line options
21
- #
22
- # @example
23
- # options = CreateGithubRelease::CommandLineOptions.new
24
- # options.release_type = 'major'
25
- # options.valid? #=> true
26
- # options.errors #=> []
27
- #
28
- # @api public
29
- #
30
- CommandLineOptions = Struct.new(
31
- :release_type, :default_branch, :release_branch, :remote, :last_release_version,
32
- :next_release_version, :changelog_path, :quiet, :verbose,
33
- keyword_init: true
34
- ) do
35
- # @attribute release_type [rw] the type of release to create
36
- #
37
- # Must be one of the VALID_RELEASE_TYPES
38
- #
39
- # @example
40
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
41
- # options.release_type #=> 'major'
42
- # @return [String]
43
- # @api public
44
-
45
- # @attribute default_branch [rw] the default branch of the repository
46
- # @example
47
- # options = CreateGithubRelease::CommandLineOptions.new(default_branch: 'main')
48
- # options.default_branch #=> 'main'
49
- # @return [String]
50
- # @api public
51
-
52
- # @attribute release_branch [rw] the branch use to create the release
53
- # @example
54
- # options = CreateGithubRelease::CommandLineOptions.new(release_branch: 'release-v1.0.0')
55
- # options.release_branch #=> 'release-v1.0.0'
56
- # @return [String]
57
- # @api public
58
-
59
- # @attribute remote [rw] the name of the remote to use to access Github
60
- # @example
61
- # options = CreateGithubRelease::CommandLineOptions.new(remote: 'origin')
62
- # options.remote #=> 'origin'
63
- # @return [String]
64
- # @api public
65
-
66
- # @attribute last_release_version [rw] the version of the last release
67
- # @example
68
- # options = CreateGithubRelease::CommandLineOptions.new(last_release_version: '0.1.1')
69
- # options.last_release_version #=> '0.1.1'
70
- # @return [String]
71
- # @api public
72
-
73
- # @attribute next_release_version [rw] the version of the next release
74
- # @example
75
- # options = CreateGithubRelease::CommandLineOptions.new(next_release_version: '1.0.0')
76
- # options.next_release_version #=> '1.0.0'
77
- # @return [String]
78
- # @api public
79
-
80
- # @attribute changelog_path [rw] the path to the changelog file
81
- # @example
82
- # options = CreateGithubRelease::CommandLineOptions.new(changelog_path: 'CHANGELOG.md')
83
- # options.changelog_path #=> 'CHANGELOG.md'
84
- # @return [String]
85
- # @api public
86
-
87
- # @attribute quiet [rw] if `true`, suppresses all output
88
- # @example
89
- # options = CreateGithubRelease::CommandLineOptions.new(quiet: true)
90
- # options.quiet #=> true
91
- # @return [Boolean]
92
- # @api public
93
-
94
- # @attribute verbose [rw] if `true`, enables verbose output
95
- # @example
96
- # options = CreateGithubRelease::CommandLineOptions.new(verbose: true)
97
- # options.verbose #=> true
98
- # @return [Boolean]
99
- # @api public
100
-
101
- # Create a new instance of this class
102
- #
103
- # @example No arguments or block given
104
- # options = CreateGithubRelease::CommandLineOptions.new
105
- # options.release_type #=> nil
106
- # options.valid? #=> false
107
- # options.errors #=> ["--release-type must be given and be one of 'major', 'minor', 'patch'"]
108
- #
109
- # @example With keyword arguments
110
- # config = { release_type: 'major', default_branch: 'main', quiet: true }
111
- # options = CreateGithubRelease::CommandLineOptions.new(**config)
112
- # options.release_type #=> 'major'
113
- # options.default_branch #=> 'main'
114
- # options.quiet #=> true
115
- # options.valid? #=> true
116
- #
117
- # @example with a configuration block
118
- # options = CreateGithubRelease::CommandLineOptions.new do |o|
119
- # o.release_type = 'major'
120
- # o.default_branch = 'main'
121
- # o.quiet = true
122
- # end
123
- # options.release_type #=> 'major'
124
- # options.default_branch #=> 'main'
125
- # options.quiet #=> true
126
- # options.valid? #=> true
127
- #
128
- # @yield [self] an initialization block
129
- # @yieldparam self [CreateGithubRelease::CommandLineOptions] the instance being initialized
130
- # @yieldreturn [void] the return value is ignored
131
- #
132
- def initialize(*)
133
- super
134
- self.quiet ||= false
135
- self.verbose ||= false
136
- @errors = []
137
- yield(self) if block_given?
138
- end
139
-
140
- # Returns `true` if all options are valid and `false` otherwise
141
- #
142
- # * If the options are valid, returns `true` clears the `#errors` array
143
- # * If the options are not valid, returns `false` and populates the `#errors` array
144
- #
145
- # @example when all options are valid
146
- # options = CreateGithubRelease::CommandLineOptions.new
147
- # options.release_type = 'major'
148
- # options.valid? #=> true
149
- # options.errors #=> []
150
- #
151
- # @example when one or more options are not valid
152
- # options = CreateGithubRelease::CommandLineOptions.new
153
- # options.release_type #=> nil
154
- # options.valid? #=> false
155
- # options.errors #=> ["--release-type must be given and be one of 'major', 'minor', 'patch'"]
156
- #
157
- # @return [Boolean]
158
- #
159
- def valid?
160
- @errors = []
161
- private_methods(false).select { |m| m.to_s.start_with?('validate_') }.each { |m| send(m) }
162
- @errors.empty?
163
- end
164
-
165
- # Returns an array of error messages
166
- #
167
- # * If the options are valid, returns an empty array
168
- # * If the options are not valid, returns an array of error messages
169
- #
170
- # @example when all options are valid
171
- # options = CreateGithubRelease::CommandLineOptions.new
172
- # options.release_type = 'major'
173
- # options.valid? #=> true
174
- # options.errors #=> []
175
- #
176
- # @example when one or more options are not valid
177
- # options = CreateGithubRelease::CommandLineOptions.new
178
- # options.release_type #=> nil
179
- # options.quiet = options.verbose = true
180
- # options.valid? #=> false
181
- # options.errors #=> [
182
- # "Both --quiet and --verbose cannot be given",
183
- # "--release-type must be given and be one of 'major', 'minor', 'patch'"
184
- # ]
185
- #
186
- # @return [Array<String>] an array of error messages
187
- #
188
- def errors
189
- valid?
190
- @errors
191
- end
192
-
193
- private
194
-
195
- # Returns `true` if the given name is a valid git reference
196
- # @return [Boolean]
197
- # @api private
198
- def valid_reference?(name)
199
- VALID_REF_PATTERN.match?(name)
200
- end
201
-
202
- # Returns `true` if the `#quiet` is `true` or `false` and `false` otherwise
203
- # @return [Boolean]
204
- # @api private
205
- def validate_quiet
206
- return true if quiet == true || quiet == false
207
-
208
- @errors << 'quiet must be either true or false'
209
- false
210
- end
211
-
212
- # Returns `true` if the `#verbose` is `true` or `false` and `false` otherwise
213
- # @return [Boolean]
214
- # @api private
215
- def validate_verbose
216
- return true if verbose == true || verbose == false
217
-
218
- @errors << 'verbose must be either true or false'
219
- false
220
- end
221
-
222
- # Returns `true` if only one of `#quiet` or `#verbose` is `true`
223
- # @return [Boolean]
224
- # @api private
225
- def validate_only_quiet_or_verbose_given
226
- return true unless quiet && verbose
227
-
228
- @errors << 'Both --quiet and --verbose cannot both be used'
229
- false
230
- end
231
-
232
- # Returns a string representation of the valid release types
233
- # @return [String]
234
- # @api private
235
- def valid_release_types
236
- "'#{VALID_RELEASE_TYPES.join("', '")}'"
237
- end
238
-
239
- # Returns `true` if the `#release_type` is not nil
240
- # @return [Boolean]
241
- # @api private
242
- def validate_release_type_given
243
- return true unless release_type.nil?
244
-
245
- @errors << "RELEASE_TYPE must be given and be one of #{valid_release_types}"
246
- false
247
- end
248
-
249
- # Returns `true` if the `#release_type` is nil or a valid release type
250
- # @return [Boolean]
251
- # @api private
252
- def validate_release_type
253
- return true if release_type.nil? || VALID_RELEASE_TYPES.include?(release_type)
254
-
255
- @errors << "RELEASE_TYPE '#{release_type}' is not valid. Must be one of #{valid_release_types}"
256
- false
257
- end
258
-
259
- # Returns `true` if the `#default_branch` is nil or is a valid git reference
260
- # @return [Boolean]
261
- # @api private
262
- def validate_default_branch
263
- return true if default_branch.nil? || valid_reference?(default_branch)
264
-
265
- @errors << "--default-branch='#{default_branch}' is not valid"
266
- false
267
- end
268
-
269
- # Returns `true` if the `#release_branch` is nil or is a valid git reference
270
- # @return [Boolean]
271
- # @api private
272
- def validate_release_branch
273
- return true if release_branch.nil? || valid_reference?(release_branch)
274
-
275
- @errors << "--release-branch='#{release_branch}' is not valid"
276
- false
277
- end
278
-
279
- # Returns `true` if the `#remote` is nil or is a valid git reference
280
- # @return [Boolean]
281
- # @api private
282
- def validate_remote
283
- return true if remote.nil? || valid_reference?(remote)
284
-
285
- @errors << "--remote='#{remote}' is not valid"
286
- false
287
- end
288
-
289
- # Returns `true` if the given version is a valid gem version
290
- # @return [Boolean]
291
- # @api private
292
- def valid_gem_version?(version)
293
- Gem::Version.new(version)
294
- true
295
- rescue ArgumentError
296
- false
297
- end
298
-
299
- # Returns `true` if the `#last_release_version` is nil or is a valid gem version
300
- # @return [Boolean]
301
- # @api private
302
- def validate_last_release_version
303
- return true if last_release_version.nil?
304
-
305
- if valid_gem_version?(last_release_version)
306
- true
307
- else
308
- @errors << "--last-release-version='#{last_release_version}' is not valid"
309
- false
310
- end
311
- end
312
-
313
- # Returns `true` if the `#next_release_version` is nil or is a valid gem version
314
- # @return [Boolean]
315
- # @api private
316
- def validate_next_release_version
317
- return true if next_release_version.nil?
318
-
319
- if valid_gem_version?(next_release_version)
320
- true
321
- else
322
- @errors << "--next-release-version='#{next_release_version}' is not valid"
323
- false
324
- end
325
- end
326
-
327
- # Returns `true` if the given path is valid
328
- # @param path [String] the path to validate
329
- # @return [Boolean]
330
- # @api private
331
- def valid_path?(path)
332
- File.expand_path(path)
333
- true
334
- rescue ArgumentError
335
- false
336
- end
337
-
338
- # Returns `true` if `#changelog_path` is nil or is a valid regular file path
339
- # @return [Boolean]
340
- # @api private
341
- def validate_changelog_path
342
- changelog_path.nil? || (changelog_path_valid? && changelog_regular_file?)
343
- end
344
-
345
- # `true` if `#changelog_path` is a valid path
346
- # @return [Boolean]
347
- # @api private
348
- def changelog_path_valid?
349
- return true if valid_path?(changelog_path)
350
-
351
- @errors << "--changelog-path='#{changelog_path}' is not valid"
352
- false
353
- end
354
-
355
- # `true` if `#changelog_path` does not exist OR if it exists and is a regular file
356
- # @return [Boolean]
357
- # @api private
358
- def changelog_regular_file?
359
- return true unless File.exist?(changelog_path) && !File.file?(changelog_path)
360
-
361
- @errors << "--changelog-path='#{changelog_path}' must be a regular file"
362
- false
363
- end
364
- end
365
- # rubocop:enable Metrics/ClassLength
366
- end
367
- # rubocop:enable Metrics/ModuleLength