create_github_release 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/CHANGELOG.md +8 -0
  4. data/README.md +156 -38
  5. data/Rakefile +6 -6
  6. data/create_github_release.gemspec +3 -3
  7. data/exe/create-github-release +1 -1
  8. data/lib/create_github_release/assertions/bundle_is_up_to_date.rb +1 -1
  9. data/lib/create_github_release/assertions/gh_authenticated.rb +1 -1
  10. data/lib/create_github_release/assertions/gh_command_exists.rb +1 -1
  11. data/lib/create_github_release/assertions/git_command_exists.rb +1 -1
  12. data/lib/create_github_release/assertions/in_git_repo.rb +1 -1
  13. data/lib/create_github_release/assertions/in_repo_root_directory.rb +1 -1
  14. data/lib/create_github_release/assertions/local_and_remote_on_same_commit.rb +1 -1
  15. data/lib/create_github_release/assertions/local_release_branch_does_not_exist.rb +1 -1
  16. data/lib/create_github_release/assertions/no_staged_changes.rb +1 -1
  17. data/lib/create_github_release/assertions/no_uncommitted_changes.rb +1 -1
  18. data/lib/create_github_release/assertions/on_default_branch.rb +1 -1
  19. data/lib/create_github_release/assertions/remote_release_branch_does_not_exist.rb +1 -1
  20. data/lib/create_github_release/assertions/remote_release_tag_does_not_exist.rb +1 -1
  21. data/lib/create_github_release/command_line/options.rb +151 -0
  22. data/lib/create_github_release/command_line/parser.rb +253 -0
  23. data/lib/create_github_release/command_line/validations.rb +293 -0
  24. data/lib/create_github_release/command_line/validator.rb +93 -0
  25. data/lib/create_github_release/command_line.rb +43 -0
  26. data/lib/create_github_release/project.rb +115 -55
  27. data/lib/create_github_release/release_assertions.rb +1 -1
  28. data/lib/create_github_release/release_tasks.rb +1 -1
  29. data/lib/create_github_release/tasks/commit_release.rb +1 -1
  30. data/lib/create_github_release/tasks/create_github_release.rb +1 -1
  31. data/lib/create_github_release/tasks/create_release_branch.rb +1 -1
  32. data/lib/create_github_release/tasks/create_release_pull_request.rb +1 -1
  33. data/lib/create_github_release/tasks/create_release_tag.rb +1 -1
  34. data/lib/create_github_release/tasks/push_release.rb +1 -1
  35. data/lib/create_github_release/tasks/update_changelog.rb +1 -1
  36. data/lib/create_github_release/tasks/update_version.rb +1 -1
  37. data/lib/create_github_release/version.rb +1 -1
  38. data/lib/create_github_release.rb +1 -2
  39. metadata +10 -34
  40. data/lib/create_github_release/command_line_options.rb +0 -378
  41. data/lib/create_github_release/command_line_parser.rb +0 -229
@@ -26,18 +26,18 @@ module CreateGithubRelease
26
26
  # used in the block passed to the initializer.
27
27
  #
28
28
  # @example calling `.new` without a block
29
- # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'minor' }
29
+ # options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'minor' }
30
30
  # project = CreateGithubRelease::Project.new(options)
31
31
  # options.release_type = 'minor'
32
32
  #
33
33
  # @example calling `.new` with a block
34
- # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'minor' }
34
+ # options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'minor' }
35
35
  # project = CreateGithubRelease::Project.new(options) do |p|
36
36
  # p.release_type = 'major'
37
37
  # end
38
38
  # options.release_type = 'major'
39
39
  #
40
- # @param options [CreateGithubRelease::CommandLineOptions] the options to initialize the instance with
40
+ # @param options [CreateGithubRelease::CommandLine::Options] the options to initialize the instance with
41
41
  #
42
42
  # @yield [self] an initialization block
43
43
  # @yieldparam self [CreateGithubRelease::Project] the instance being initialized aka `self`
@@ -55,20 +55,21 @@ module CreateGithubRelease
55
55
  # The command line options used to initialize this project
56
56
  #
57
57
  # @example
58
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
58
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
59
59
  # project = CreateGithubRelease::Project.new(options)
60
60
  # project.options == options #=> true
61
61
  #
62
- # @return [CreateGithubRelease::CommandLineOptions]
62
+ # @return [CreateGithubRelease::CommandLine::Options]
63
63
  #
64
64
  attr_reader :options
65
65
 
66
66
  attr_writer \
67
67
  :default_branch, :next_release_tag, :next_release_date, :next_release_version,
68
68
  :last_release_tag, :last_release_version, :release_branch, :release_log_url,
69
- :release_type, :release_url, :remote, :remote_base_url, :remote_repository, :remote_url,
70
- :changelog_path, :changes, :next_release_description, :last_release_changelog,
71
- :next_release_changelog, :first_commit, :verbose, :quiet
69
+ :release_type, :pre, :pre_type, :release_url, :remote, :remote_base_url,
70
+ :remote_repository, :remote_url, :changelog_path, :changes,
71
+ :next_release_description, :last_release_changelog, :next_release_changelog,
72
+ :first_commit, :verbose, :quiet
72
73
 
73
74
  # attr_writer :first_release
74
75
 
@@ -82,12 +83,12 @@ module CreateGithubRelease
82
83
  # Uses the value of `remote` to determine the remote repository to query.
83
84
  #
84
85
  # @example By default, `default_branch` is based on `git remote show`
85
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
86
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
86
87
  # project = CreateGithubRelease::Project.new(options)
87
88
  # options.default_branch # => 'main'
88
89
  #
89
90
  # @example `default_branch` can be set explicitly
90
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
91
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
91
92
  # project = CreateGithubRelease::Project.new(options)
92
93
  # project.default_branch = 'master'
93
94
  # project.default_branch #=> 'master'
@@ -114,13 +115,13 @@ module CreateGithubRelease
114
115
  # Uses the value of `next_release_version` to determine the tag name.
115
116
  #
116
117
  # @example By default, `next_release_tag` is based on `next_release_version`
117
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
118
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
118
119
  # project = CreateGithubRelease::Project.new(options)
119
120
  # project.next_release_version = '1.0.0'
120
121
  # project.next_relase_tag #=> 'v1.0.0'
121
122
  #
122
123
  # @example `next_tag` can be set explicitly
123
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
124
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
124
125
  # project = CreateGithubRelease::Project.new(options)
125
126
  # project.next_release_tag = 'v1.0.0'
126
127
  # project.next_relase_tag #=> 'v1.0.0'
@@ -140,13 +141,13 @@ module CreateGithubRelease
140
141
  # If the next_release_tag does not exist, Date.today is returned.
141
142
  #
142
143
  # @example By default, `next_release_date` is based on `next_release_tag`
143
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
144
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
144
145
  # project = CreateGithubRelease::Project.new(options)
145
146
  # project.next_release_tag = 'v1.0.0'
146
147
  # project.next_release_date #=> #<Date: 2023-02-01 ((2459189j,0s,0n),+0s,2299161j)>
147
148
  #
148
149
  # @example It can also be set explicitly
149
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
150
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
150
151
  # project = CreateGithubRelease::Project.new(options)
151
152
  # project.next_release_date = Date.new(2023, 2, 1)
152
153
  # project.next_release_date #=> #<Date: 2023-02-01 ((2459189j,0s,0n),+0s,2299161j)>
@@ -172,7 +173,7 @@ module CreateGithubRelease
172
173
  # `true` if the given tag exists in the local repository
173
174
  #
174
175
  # @example
175
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
176
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
176
177
  # project = CreateGithubRelease::Project.new(options)
177
178
  # project.tag_exist?('v1.0.0') #=> false
178
179
  #
@@ -194,12 +195,12 @@ module CreateGithubRelease
194
195
  # The version of the next release
195
196
  #
196
197
  # @example By default, `next_release_version` is based on the value returned by `semverify <release_type> --dry-run`
197
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
198
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
198
199
  # project = CreateGithubRelease::Project.new(options)
199
200
  # project.next_release_version #=> '1.0.0'
200
201
  #
201
202
  # @example It can also be set explicitly
202
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
203
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
203
204
  # project = CreateGithubRelease::Project.new(options)
204
205
  # project.next_release_version = '1.0.0
205
206
  # project.next_release_version #=> '1.0.0'
@@ -221,13 +222,13 @@ module CreateGithubRelease
221
222
  # Uses the value of `last_release_version` to determine the tag name.
222
223
  #
223
224
  # @example By default, `last_release_tag` is based on `last_release_version`
224
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
225
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
225
226
  # project = CreateGithubRelease::Project.new(options)
226
227
  # project.last_release_version = '0.0.1'
227
228
  # project.last_relase_tag #=> 'v0.0.1'
228
229
  #
229
230
  # @example `last_release_tag` can be set explicitly
230
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
231
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
231
232
  # project = CreateGithubRelease::Project.new(options)
232
233
  # project.last_release_tag = 'v0.0.1'
233
234
  # project.last_relase_tag #=> 'v0.0.1'
@@ -245,12 +246,12 @@ module CreateGithubRelease
245
246
  # The version of the last release
246
247
  #
247
248
  # @example By default, `last_release_version` is based on the value returned by `semverify current`
248
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
249
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
249
250
  # project = CreateGithubRelease::Project.new(options)
250
251
  # project.last_release_version #=> '0.0.1'
251
252
  #
252
253
  # @example It can also be set explicitly
253
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
254
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
254
255
  # project = CreateGithubRelease::Project.new(options)
255
256
  # project.last_release_version = '0.0.1
256
257
  # project.last_release_version #=> '0.0.1'
@@ -270,13 +271,13 @@ module CreateGithubRelease
270
271
  # The name of the release branch being created
271
272
  #
272
273
  # @example By default, `release_branch` is based on the value returned by `next_release_tag`
273
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
274
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
274
275
  # project = CreateGithubRelease::Project.new(options)
275
276
  # project.next_release_tag = 'v1.0.0'
276
277
  # project.release_branch #=> 'release-v1.0.0'
277
278
  #
278
279
  # @example It can also be set explicitly
279
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
280
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
280
281
  # project = CreateGithubRelease::Project.new(options)
281
282
  # project.next_release_branch = 'release-v1.0.0'
282
283
  # project.next_release_branch #=> 'release-v1.0.0'
@@ -296,7 +297,7 @@ module CreateGithubRelease
296
297
  # The URL of the page containing a list of the changes in the release
297
298
  #
298
299
  # @example By default, `release_log_url` is based on `remote_url`, `last_release_tag`, and `next_release_tag`
299
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
300
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
300
301
  # project = CreateGithubRelease::Project.new(options)
301
302
  # project.remote_url = URI.parse('https://github.com/org/repo')
302
303
  # project.last_release_tag = 'v0.0.1'
@@ -304,7 +305,7 @@ module CreateGithubRelease
304
305
  # project.release_log_url #=> #<URI::HTTPS https://github.com/org/repo/compare/v0.0.1..v1.0.0>
305
306
  #
306
307
  # @example It can also be set explicitly
307
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
308
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
308
309
  # project = CreateGithubRelease::Project.new(options)
309
310
  # project.release_log_url = URI.parse('https://github.com/org/repo/compare/v0.0.1..v1.0.0')
310
311
  # project.release_log_url #=> #<URI::HTTPS https://github.com/org/repo/compare/v0.0.1..v1.0.0>
@@ -330,12 +331,12 @@ module CreateGithubRelease
330
331
  # @note this must be one of the values accepted by the `semverify` command
331
332
  #
332
333
  # @example By default, this value comes from the options object
333
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
334
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
334
335
  # project = CreateGithubRelease::Project.new(options)
335
336
  # project.release_type #=> 'major'
336
337
  #
337
338
  # @example It can also be set explicitly
338
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
339
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
339
340
  # project = CreateGithubRelease::Project.new(options)
340
341
  # project.release_type = 'patch'
341
342
  # project.release_type #=> 'patch'
@@ -350,19 +351,66 @@ module CreateGithubRelease
350
351
  @release_type ||= options.release_type || raise(ArgumentError, 'release_type is required')
351
352
  end
352
353
 
354
+ # @!attribute [rw] pre
355
+ #
356
+ # Set to true if a pre-release is be created
357
+ #
358
+ # @example By default, this value comes from the options object
359
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', pre: true, pre_type: 'alpha')
360
+ # project = CreateGithubRelease::Project.new(options)
361
+ # project.pre #=> 'true'
362
+ #
363
+ # @example It can also be set explicitly
364
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
365
+ # project = CreateGithubRelease::Project.new(options)
366
+ # project.pre = true
367
+ # project.pre #=> true
368
+ #
369
+ # @return [Boolean]
370
+ #
371
+ # @api public
372
+ #
373
+ def pre
374
+ @pre ||= options.pre
375
+ end
376
+
377
+ # @!attribute [rw] pre_type
378
+ #
379
+ # Set to the pre-release type to create. For example, "alpha", "beta", "pre", etc
380
+ #
381
+ # @example By default, this value comes from the options object
382
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', pre: true, pre_type: 'alpha')
383
+ # project = CreateGithubRelease::Project.new(options)
384
+ # project.pre_type #=> 'alpha'
385
+ #
386
+ # @example It can also be set explicitly
387
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
388
+ # project = CreateGithubRelease::Project.new(options)
389
+ # project.pre = true
390
+ # project.pre_type = 'alpha'
391
+ # project.pre_type #=> 'alpha'
392
+ #
393
+ # @return [String]
394
+ #
395
+ # @api public
396
+ #
397
+ def pre_type
398
+ @pre_type ||= options.pre_type
399
+ end
400
+
353
401
  # @!attribute [rw] release_url
354
402
  #
355
403
  # The URL of the page containing a list of the changes in the release
356
404
  #
357
405
  # @example By default, `release_url` is based on `remote_url` and `next_release_tag`
358
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
406
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
359
407
  # project = CreateGithubRelease::Project.new(options)
360
408
  # project.remote_url = URI.parse('https://github.com/org/repo')
361
409
  # project.next_release_tag = 'v1.0.0'
362
410
  # project.release_url #=> #<URI::HTTPS https://github.com/org/repo/releases/tag/v1.0.0>
363
411
  #
364
412
  # @example It can also be set explicitly
365
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
413
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
366
414
  # project = CreateGithubRelease::Project.new(options)
367
415
  # project.release_url = URI.parse('https://github.com/org/repo/releases/tag/v1.0.0')
368
416
  # project.release_url #=> #<URI::HTTPS https://github.com/org/repo/releases/tag/v1.0.0>
@@ -380,17 +428,17 @@ module CreateGithubRelease
380
428
  # The git remote used to determine the repository url
381
429
  #
382
430
  # @example By default, 'origin' is used
383
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
431
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
384
432
  # project = CreateGithubRelease::Project.new(options)
385
433
  # project.remote #=> 'origin'
386
434
  #
387
435
  # @example It can also be set in the options
388
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major', remote: 'upstream')
436
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', remote: 'upstream')
389
437
  # project = CreateGithubRelease::Project.new(options)
390
438
  # project.remote #=> 'upstream'
391
439
  #
392
440
  # @example It can also be set explicitly
393
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
441
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
394
442
  # project = CreateGithubRelease::Project.new(options)
395
443
  # project.remote = 'upstream'
396
444
  # project.remote #=> 'upstream'
@@ -408,13 +456,13 @@ module CreateGithubRelease
408
456
  # The base part of the remote url (e.g. 'https://github.com/')
409
457
  #
410
458
  # @example By default, this value is based on `remote_url`
411
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
459
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
412
460
  # project = CreateGithubRelease::Project.new(options)
413
461
  # project.remote_url = URI.parse('https://github.com/org/repo')
414
462
  # project.remote #=> #<URI::HTTPS https://github.com/>
415
463
  #
416
464
  # @example It can also be set explicitly
417
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
465
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
418
466
  # project = CreateGithubRelease::Project.new(options)
419
467
  # project.remote_base_url = URI.parse('https://github.com/')
420
468
  # project.remote_base_url #=> #<URI::HTTPS https://github.com/>
@@ -432,13 +480,13 @@ module CreateGithubRelease
432
480
  # The git remote owner and repository name (e.g. 'org/repo')
433
481
  #
434
482
  # @example By default, this value is based on `remote_url`
435
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
483
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
436
484
  # project = CreateGithubRelease::Project.new(options)
437
485
  # project.remote_url = URI.parse('htps://github.com/org/repo')
438
486
  # project.remote_repository #=> 'org/repo'
439
487
  #
440
488
  # @example It can also be set explicitly
441
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
489
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
442
490
  # project = CreateGithubRelease::Project.new(options)
443
491
  # project.remote_repository = 'org/repo'
444
492
  #
@@ -455,12 +503,12 @@ module CreateGithubRelease
455
503
  # The URL of the git remote repository (e.g. 'https://github.com/org/repo')
456
504
  #
457
505
  # @example By default, this value is based on `remote` and the `git remote get-url` command
458
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
506
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
459
507
  # project = CreateGithubRelease::Project.new(options)
460
508
  # project.remote #=> #<URI::HTTPS https://github.com/org/repo>
461
509
  #
462
510
  # @example It can also be set explicitly
463
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
511
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
464
512
  # project = CreateGithubRelease::Project.new(options)
465
513
  # project.remote_url = URI.parse('https://github.com/org/repo')
466
514
  # project.remote_url #=> #<URI::HTTPS https://github.com/org/repo>
@@ -485,17 +533,19 @@ module CreateGithubRelease
485
533
  # The path relative to the project root where the changelog is located
486
534
  #
487
535
  # @example By default, this value is 'CHANGELOG.md'
488
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
536
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
489
537
  # project = CreateGithubRelease::Project.new(options)
490
538
  # project.changelog_path #=> 'CHANGELOG.md'
491
539
  #
492
540
  # @example It can also be set in the options
493
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major', changelog_path: 'docs/CHANGES.txt')
541
+ # options = CreateGithubRelease::CommandLine::Options.new(
542
+ # release_type: 'major', changelog_path: 'docs/CHANGES.txt'
543
+ # )
494
544
  # project = CreateGithubRelease::Project.new(options)
495
545
  # project.remote_repository = 'docs/CHANGES.txt'
496
546
  #
497
547
  # @example It can also be set explicitly
498
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
548
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
499
549
  # project = CreateGithubRelease::Project.new(options)
500
550
  # project.changelog_path = 'docs/CHANGES.txt'
501
551
  # project.remote_repository = 'docs/CHANGES.txt'
@@ -515,7 +565,7 @@ module CreateGithubRelease
515
565
  # Calls `git log HEAD <next_release_tag>` to list the changes.
516
566
  #
517
567
  # @example By default, uses `git log`
518
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
568
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
519
569
  # project = CreateGithubRelease::Project.new(options)
520
570
  # pp project.changes
521
571
  # [
@@ -524,7 +574,7 @@ module CreateGithubRelease
524
574
  # ]
525
575
  #
526
576
  # @example It can also be set explicitly
527
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
577
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
528
578
  # project = CreateGithubRelease::Project.new(options)
529
579
  # project.changes = 'All the changes'
530
580
  # project.changes #=> 'All the changes'
@@ -550,7 +600,7 @@ module CreateGithubRelease
550
600
  # The formatted release description
551
601
  #
552
602
  # @example
553
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
603
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
554
604
  # project = CreateGithubRelease::Project.new(options) do |p|
555
605
  # p.remote_url = URI.parse('https://github.com/username/repo')
556
606
  # p.last_release_tag = 'v0.1.0'
@@ -601,7 +651,7 @@ module CreateGithubRelease
601
651
  #
602
652
  # * e718690 Release v0.1.0 (#3)
603
653
  # CHANGELOG
604
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
654
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
605
655
  # project = CreateGithubRelease::Project.new(options) do |p|
606
656
  # p.changelog_path = changelog_path
607
657
  # end
@@ -634,7 +684,7 @@ module CreateGithubRelease
634
684
  # last_release_changelog.
635
685
  #
636
686
  # @example
637
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
687
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
638
688
  # project = CreateGithubRelease::Project.new(options) do |p|
639
689
  # p.last_release_changelog = <<~CHANGELOG
640
690
  # # Project Changelog
@@ -666,7 +716,7 @@ module CreateGithubRelease
666
716
  # Show the project details as a string
667
717
  #
668
718
  # @example
669
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
719
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
670
720
  # project = CreateGithubRelease::Project.new(options)
671
721
  # puts projects.to_s
672
722
  # default_branch: main
@@ -718,12 +768,12 @@ module CreateGithubRelease
718
768
  # If `true` enables verbose output
719
769
  #
720
770
  # @example By default, this value is based on the `verbose` option
721
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major', verbose: true)
771
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', verbose: true)
722
772
  # project = CreateGithubRelease::Project.new(options)
723
773
  # project.verbose? #=> true
724
774
  #
725
775
  # @example It can also be set explicitly
726
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
776
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
727
777
  # project = CreateGithubRelease::Project.new(options)
728
778
  # project.verbose = true
729
779
  # project.verbose? #=> true
@@ -743,12 +793,12 @@ module CreateGithubRelease
743
793
  # If `true` supresses all output
744
794
  #
745
795
  # @example By default, this value is based on the `quiet` option
746
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major', quiet: true)
796
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major', quiet: true)
747
797
  # project = CreateGithubRelease::Project.new(options)
748
798
  # project.quiet? #=> true
749
799
  #
750
800
  # @example It can also be set explicitly
751
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
801
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
752
802
  # project = CreateGithubRelease::Project.new(options)
753
803
  # project.quiet = true
754
804
  # project.quiet? #=> true
@@ -768,12 +818,12 @@ module CreateGithubRelease
768
818
  # true if release_type is 'first' otherwise false
769
819
  #
770
820
  # @example Returns true if release_type is 'first'
771
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'first')
821
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'first')
772
822
  # project = CreateGithubRelease::Project.new(options)
773
823
  # project.first_release? #=> true
774
824
  #
775
825
  # @example Returnss false if release_type is not 'first'
776
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
826
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
777
827
  # project = CreateGithubRelease::Project.new(options)
778
828
  # project.first_release? #=> false
779
829
  #
@@ -792,7 +842,7 @@ module CreateGithubRelease
792
842
  # The SHA of the oldest commit that is an ancestor of HEAD
793
843
  #
794
844
  # @example
795
- # options = CreateGithubRelease::CommandLineOptions.new(release_type: 'major')
845
+ # options = CreateGithubRelease::CommandLine::Options.new(release_type: 'major')
796
846
  # project = CreateGithubRelease::Project.new(options)
797
847
  # project.first_commit? #=> '1234567'
798
848
  #
@@ -826,12 +876,22 @@ module CreateGithubRelease
826
876
  # @return [String] The next version of the project
827
877
  # @api private
828
878
  def next_version
829
- output = `semverify next-#{release_type} --dry-run`
879
+ output = `#{next_version_cmd}`
830
880
  raise 'Could not determine next version using semverify' unless $CHILD_STATUS.success?
831
881
 
832
882
  output.lines.last.chomp
833
883
  end
834
884
 
885
+ # Construct the command used to get the next version
886
+ # @return [String]
887
+ # @api private
888
+ def next_version_cmd
889
+ cmd = "semverify next-#{release_type}"
890
+ cmd << ' --pre' if pre
891
+ cmd << " --pre-type=#{pre_type}" if pre_type
892
+ cmd << ' --dry-run'
893
+ end
894
+
835
895
  # Setup versions and tags for a first release
836
896
  # @return [void]
837
897
  # @api private
@@ -24,7 +24,7 @@ module CreateGithubRelease
24
24
  # assertions = CreateGithubRelease::ReleaseAssertions.new(options)
25
25
  # assertions.options # => #<CreateGithubRelease::Options:0x00007f9b0a0b0a00>
26
26
  #
27
- # @return [CreateGithubRelease::CommandLineOptions]
27
+ # @return [CreateGithubRelease::CommandLine::Options]
28
28
  attr_reader :options
29
29
 
30
30
  # Create a new instance of ReleaseAssertions
@@ -24,7 +24,7 @@ module CreateGithubRelease
24
24
  # tasks = CreateGithubRelease::ReleaseTasks.new(options)
25
25
  # tasks.options # => #<CreateGithubRelease::Options:0x00007f9b0a0b0a00>
26
26
  #
27
- # @return [CreateGithubRelease::CommandLineOptions]
27
+ # @return [CreateGithubRelease::CommandLine::Options]
28
28
  attr_reader :options
29
29
 
30
30
  # Create a new instance of ReleaseTasks
@@ -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::CommitRelease.new(project)
21
21
  # begin
@@ -16,7 +16,7 @@ module CreateGithubRelease
16
16
  # @example
17
17
  # require 'create_github_release'
18
18
  #
19
- # options = CreateGithubRelease::CommandLineOptions.new { |o| o.release_type = 'major' }
19
+ # options = CreateGithubRelease::CommandLine::Options.new { |o| o.release_type = 'major' }
20
20
  # project = CreateGithubRelease::Project.new(options)
21
21
  # task = CreateGithubRelease::Tasks::CreateGithubRelease.new(project)
22
22
  # 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::CreateReleaseBranch.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::CreateReleasePullRequest.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::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
@@ -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::UpdateVersion.new(project)
21
21
  # begin
@@ -2,5 +2,5 @@
2
2
 
3
3
  module CreateGithubRelease
4
4
  # The version of this gem
5
- VERSION = '1.1.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'