nextver 0.2.0 → 0.3.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 -0
- data/bin/nextver +2 -1
- data/lib/nextver/version.rb +1 -1
- data/lib/nextver.rb +7 -5
- 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: 5bb8461f23e755657657651af9c58f17e7bd01079495fa04b2aae42c4634d688
|
|
4
|
+
data.tar.gz: 69b372968a5a0d00bd4c70568e130485d723a6d0ee6839e52240ff4df1d1443a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 482823e6a7272e67576d043f275b66ff525ef4a6d825f58d66ccb4ac494b8cc2d4e70f09df200e97afe901a66ee1f7f9ff64d2ac9707ec7c345be57ca06a67aa
|
|
7
|
+
data.tar.gz: 57b139973304c592122e90d4e0dae5bdee939f393171ba11d44826b2ef8749fa2f88bb6057c1e38e4b1bb3a5b2b6d58203c88c02923dc447d948c92ca08ef261
|
data/README.md
CHANGED
|
@@ -26,6 +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
30
|
-n Version is not prefixed by v, for example, 1.0.0.
|
|
30
31
|
-t Show detected latest version.
|
|
31
32
|
-v Show version of nextver.
|
data/bin/nextver
CHANGED
|
@@ -6,6 +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
10
|
o.on("-e", "Suppress trailing new line. Print only version out.") { opts[:no_newline] = true }
|
|
10
11
|
o.on("-n", "Version is not prefixed by v, for example, 1.0.0.") { opts[:no_prefix] = true }
|
|
11
12
|
o.on("-t", "Show detected latest version.") { opts[:latest] = true }
|
|
@@ -16,7 +17,7 @@ end
|
|
|
16
17
|
begin
|
|
17
18
|
parser.parse!
|
|
18
19
|
log = ->(msg) { puts msg if opts[:debug] }
|
|
19
|
-
repo = Nextver::Repo.new(ARGV[0] || ".", prefixed: !opts[:no_prefix], log: log)
|
|
20
|
+
repo = Nextver::Repo.new(ARGV[0] || ".", prefixed: !opts[:no_prefix], force: opts[:force], log: log)
|
|
20
21
|
current = repo.current_version
|
|
21
22
|
|
|
22
23
|
if opts[:latest]
|
data/lib/nextver/version.rb
CHANGED
data/lib/nextver.rb
CHANGED
|
@@ -22,19 +22,20 @@ module Nextver
|
|
|
22
22
|
parts[0, 3] + (parts[3] ? [0, parts[3]] : [1, ""])
|
|
23
23
|
end
|
|
24
24
|
|
|
25
|
-
# :major, :minor, :patch or nil for a single commit message.
|
|
26
|
-
def bump(message)
|
|
25
|
+
# :major, :minor, :patch or nil for a single commit message. +force+ makes other conventional types :patch.
|
|
26
|
+
def bump(message, force: false)
|
|
27
27
|
header = HEADER.match(message.strip) or return nil
|
|
28
28
|
return :major if header[1] || message.lines.drop(1).any? { |l| l =~ BREAKING_FOOTER }
|
|
29
|
-
{ "feat" => :minor, "fix" => :patch }
|
|
29
|
+
{ "feat" => :minor, "fix" => :patch }.fetch(message[/\A\w+/], force ? :patch : nil)
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
class Repo
|
|
33
|
-
def initialize(dir = ".", prefixed: true, log: nil)
|
|
33
|
+
def initialize(dir = ".", prefixed: true, force: false, log: nil)
|
|
34
34
|
raise Error, "target path is not git repo path" unless File.directory?(File.join(dir, ".git"))
|
|
35
35
|
@dir = dir
|
|
36
36
|
@prefix = prefixed ? "v" : ""
|
|
37
37
|
@prefixed = prefixed
|
|
38
|
+
@force = force
|
|
38
39
|
@log = log || ->(_) {}
|
|
39
40
|
end
|
|
40
41
|
|
|
@@ -46,6 +47,7 @@ module Nextver
|
|
|
46
47
|
|
|
47
48
|
def next_version(current = current_version)
|
|
48
49
|
@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
|
|
49
51
|
unless current
|
|
50
52
|
@log.call("Current version is missing. Start a new one at v1.0.0.")
|
|
51
53
|
return "#{@prefix}1.0.0"
|
|
@@ -56,7 +58,7 @@ module Nextver
|
|
|
56
58
|
messages = git("log", "--format=%B%x00", "#{current}..HEAD").split("\0").map(&:strip).reject(&:empty?)
|
|
57
59
|
@log.call("#{messages.size} commit(s) since latest tag")
|
|
58
60
|
|
|
59
|
-
counts = messages.map { |m| Nextver.bump(m) }.compact.group_by(&:itself).transform_values(&:size)
|
|
61
|
+
counts = messages.map { |m| Nextver.bump(m, force: @force) }.compact.group_by(&:itself).transform_values(&:size)
|
|
60
62
|
@log.call("============\nCommit stats\n------------")
|
|
61
63
|
@log.call("Major change(s) = #{counts.fetch(:major, 0)}")
|
|
62
64
|
@log.call("Minor change(s) = #{counts.fetch(:minor, 0)}")
|