nextver 0.3.0 → 0.4.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: 5bb8461f23e755657657651af9c58f17e7bd01079495fa04b2aae42c4634d688
4
- data.tar.gz: 69b372968a5a0d00bd4c70568e130485d723a6d0ee6839e52240ff4df1d1443a
3
+ metadata.gz: 33c4498c88b85d30319159d4d87d712dcd308e55eadc3eebc76843999a88756e
4
+ data.tar.gz: 9f3d97eda985aa440780513806134fdd02d7aeb41b2eac106114eb0a90703d0b
5
5
  SHA512:
6
- metadata.gz: 482823e6a7272e67576d043f275b66ff525ef4a6d825f58d66ccb4ac494b8cc2d4e70f09df200e97afe901a66ee1f7f9ff64d2ac9707ec7c345be57ca06a67aa
7
- data.tar.gz: 57b139973304c592122e90d4e0dae5bdee939f393171ba11d44826b2ef8749fa2f88bb6057c1e38e4b1bb3a5b2b6d58203c88c02923dc447d948c92ca08ef261
6
+ metadata.gz: e7531c23b2c3f360206502a9f1b890917f3e3367dd65e4516dd6a2c39f189aecff91d7c94b8eaad171dae98861e51bd99d71935c48a07c101b14ca7c11c801de
7
+ data.tar.gz: e6a0cc48b82a1bdfa4e8971f51565fc29395616a57e4a8638382a6662622d03605039475e75f1280b17cfc7eaa50b713ae88431d30437e60bf49056ead7289ad
data/README.md CHANGED
@@ -26,7 +26,7 @@ bin/nextver [options...] [dir]
26
26
 
27
27
  -d Debug mode, print considering steps.
28
28
  -e Suppress trailing new line. Print only version out.
29
- -f Force non-feat/fix commits to bump patch.
29
+ -f Force other commit types to bump patch.
30
30
  -n Version is not prefixed by v, for example, 1.0.0.
31
31
  -t Show detected latest version.
32
32
  -v Show version of nextver.
data/bin/nextver CHANGED
@@ -6,7 +6,7 @@ opts = {}
6
6
  parser = OptionParser.new do |o|
7
7
  o.banner = "Usage of nextver:\n\n nextver [options...] [dir]\n\nOptions:"
8
8
  o.on("-d", "Debug mode, print considering steps.") { opts[:debug] = true }
9
- o.on("-f", "Force non-feat/fix commits to bump patch.") { opts[:force] = true }
9
+ o.on("-f", "Force other commit types to bump patch.") { opts[:force] = true }
10
10
  o.on("-e", "Suppress trailing new line. Print only version out.") { opts[:no_newline] = true }
11
11
  o.on("-n", "Version is not prefixed by v, for example, 1.0.0.") { opts[:no_prefix] = true }
12
12
  o.on("-t", "Show detected latest version.") { opts[:latest] = true }
@@ -1,3 +1,3 @@
1
1
  module Nextver
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/nextver.rb CHANGED
@@ -8,6 +8,7 @@ module Nextver
8
8
  SEMVER = /\Av(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?)?)?\z/
9
9
  HEADER = /\A\w+(?:\([\w-]+\))?(!)?: .+/
10
10
  BREAKING_FOOTER = /^BREAKING[ -]CHANGE(?:: | #)/
11
+ BUMPS = { "feat" => :minor }.merge(%w[fix chore doc docs style styles refactor].to_h { |t| [t, :patch] }).freeze
11
12
 
12
13
  module_function
13
14
 
@@ -22,11 +23,11 @@ module Nextver
22
23
  parts[0, 3] + (parts[3] ? [0, parts[3]] : [1, ""])
23
24
  end
24
25
 
25
- # :major, :minor, :patch or nil for a single commit message. +force+ makes other conventional types :patch.
26
+ # :major, :minor, :patch or nil for a single commit message. +force+ makes types outside BUMPS :patch.
26
27
  def bump(message, force: false)
27
28
  header = HEADER.match(message.strip) or return nil
28
29
  return :major if header[1] || message.lines.drop(1).any? { |l| l =~ BREAKING_FOOTER }
29
- { "feat" => :minor, "fix" => :patch }.fetch(message[/\A\w+/], force ? :patch : nil)
30
+ BUMPS.fetch(message[/\A\w+/], force ? :patch : nil)
30
31
  end
31
32
 
32
33
  class Repo
@@ -47,7 +48,7 @@ module Nextver
47
48
 
48
49
  def next_version(current = current_version)
49
50
  @log.call(@prefixed ? "Version is prefixed by v." : "Version is not prefixed by v.")
50
- @log.call("Forcing non-feat/fix commits to bump patch.") if @force
51
+ @log.call("Forcing all other commit types to bump patch.") if @force
51
52
  unless current
52
53
  @log.call("Current version is missing. Start a new one at v1.0.0.")
53
54
  return "#{@prefix}1.0.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nextver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chonlasith Jucksriporn