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 +4 -4
- data/README.md +1 -1
- data/bin/nextver +1 -1
- data/lib/nextver/version.rb +1 -1
- data/lib/nextver.rb +4 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 33c4498c88b85d30319159d4d87d712dcd308e55eadc3eebc76843999a88756e
|
|
4
|
+
data.tar.gz: 9f3d97eda985aa440780513806134fdd02d7aeb41b2eac106114eb0a90703d0b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
|
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 }
|
data/lib/nextver/version.rb
CHANGED
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
|
|
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
|
-
|
|
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
|
|
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"
|