fastlane-plugin-semantic_versioning 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8564caab2d111a1099b9c876d794673d124b89fea24c4d6ef3b7886f096e9c5
|
4
|
+
data.tar.gz: cf726334226530356e0180b112080ffb30bce81aa6709c9b072ac9d152070234
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7119102889ba20b58d153f92cbd9ae6d7b118c3e01c963773bfd0a1320976f5a55e336e9356822f2f64e2bc5be6e08fb6b61151ac005fc6c73fbdc1867ee5b90
|
7
|
+
data.tar.gz: bf0e95b1a39df59564cf3b47e6418fb8cc754d7a6f53b0ccce793f1e93557336e5ce988a17d711f7b26a9acaf8672ee0183226013867af3e39cdd0f48abe038c
|
@@ -18,6 +18,7 @@ module Fastlane
|
|
18
18
|
params[:allowed_types].map!(&:to_sym)
|
19
19
|
params[:bump_map].transform_keys!(&:to_sym)
|
20
20
|
params[:bump_map].transform_values!(&:to_sym)
|
21
|
+
params[:force_type] = params[:force_type]&.to_sym
|
21
22
|
|
22
23
|
UI.message("The semantic_versioning plugin is working!")
|
23
24
|
|
@@ -26,10 +27,11 @@ module Fastlane
|
|
26
27
|
|
27
28
|
commits = Helper::SemanticVersioningHelper.git_commits(
|
28
29
|
from: Helper::SemanticVersioningHelper.git_tag_exists?(formatted_tag) ? formatted_tag : nil,
|
29
|
-
allowed_types: params[:allowed_types]
|
30
|
+
allowed_types: params[:allowed_types],
|
31
|
+
bump_map: params[:bump_map]
|
30
32
|
)
|
31
33
|
|
32
|
-
bump_type = Helper::SemanticVersioningHelper.bump_type(commits: commits,
|
34
|
+
bump_type = Helper::SemanticVersioningHelper.bump_type(commits: commits, force_type: params[:force_type])
|
33
35
|
new_version = Helper::SemanticVersioningHelper.increase_version(current_version: current_version, bump_type: bump_type)
|
34
36
|
new_changelog = Helper::SemanticVersioningHelper.build_changelog(version: new_version, commits: commits, type_map: params[:type_map])
|
35
37
|
bumpable = current_version != new_version
|
@@ -88,6 +90,12 @@ module Fastlane
|
|
88
90
|
default_value: { breaking: :major, feat: :minor, fix: :patch },
|
89
91
|
is_string: false,
|
90
92
|
verify_block: ->(value) { verify_bump_map(value) }),
|
93
|
+
FastlaneCore::ConfigItem.new(key: :force_type,
|
94
|
+
env_name: "SEMANTIC_VERSIONING_FORCE_TYPE",
|
95
|
+
description: "Force a minimum bump type",
|
96
|
+
optional: true,
|
97
|
+
default_value: nil,
|
98
|
+
type: String),
|
91
99
|
FastlaneCore::ConfigItem.new(key: :tag_format,
|
92
100
|
env_name: "SEMANTIC_VERSIONING_TAG_FORMAT",
|
93
101
|
description: "The format for the git tag",
|
@@ -27,36 +27,53 @@ module Fastlane
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Retrieves git commits and returns them grouped by type
|
30
|
-
def self.git_commits(from:, allowed_types:)
|
30
|
+
def self.git_commits(from:, allowed_types:, bump_map:)
|
31
31
|
logs = from ? git.log(-1).between(from) : git.log(-1)
|
32
32
|
logs.reverse_each.map do |commit|
|
33
|
-
parse_conventional_commit(commit: commit, allowed_types: allowed_types)
|
33
|
+
parse_conventional_commit(commit: commit, allowed_types: allowed_types, bump_map: bump_map)
|
34
34
|
end.compact
|
35
35
|
end
|
36
36
|
|
37
|
-
def self.
|
38
|
-
|
37
|
+
def self.parse_conventional_commit(commit:, allowed_types:, bump_map:)
|
38
|
+
types = allowed_types.join("|")
|
39
|
+
commit.message.match(/^(?<type>#{types})(\((?<scope>\S+)\))?(?<major>!)?:\s+(?<subject>[^\n\r]+)(\z|\n\n(?<body>.*\z))/m) do |match|
|
40
|
+
cc = {
|
41
|
+
type: match[:type].to_sym,
|
42
|
+
major: !!match[:major],
|
43
|
+
scope: match[:scope],
|
44
|
+
subject: match[:subject],
|
45
|
+
body: match[:body],
|
46
|
+
breaking: nil,
|
47
|
+
original_message: commit.message
|
48
|
+
}
|
39
49
|
|
40
|
-
|
41
|
-
|
42
|
-
result[:breaking] << commit
|
50
|
+
match[:body]&.match(/^BREAKING CHANGE?: (.+)\z/) do |breaking|
|
51
|
+
cc[:breaking] = breaking[1]
|
43
52
|
end
|
44
|
-
next unless allowed_types.include?(commit[:type])
|
45
53
|
|
46
|
-
|
47
|
-
next if commit[:breaking] == commit[:subject]
|
54
|
+
cc[:bump] = commit_bump_type(commit: cc, bump_map: bump_map)
|
48
55
|
|
49
|
-
|
56
|
+
return cc
|
50
57
|
end
|
58
|
+
end
|
51
59
|
|
52
|
-
|
60
|
+
def self.commit_bump_type(commit:, bump_map:)
|
61
|
+
return :major if commit[:major]
|
62
|
+
|
63
|
+
return bump_map[:breaking] if commit[:breaking]
|
64
|
+
|
65
|
+
return bump_map[commit[:type]]
|
53
66
|
end
|
54
67
|
|
55
|
-
def self.bump_type(commits:,
|
56
|
-
|
68
|
+
def self.bump_type(commits:, force_type: nil)
|
69
|
+
return force_type if force_type == :major # can't go any higher
|
70
|
+
|
71
|
+
result = force_type
|
57
72
|
|
58
73
|
commits.each do |commit|
|
59
|
-
|
74
|
+
return :major if commit[:major]
|
75
|
+
|
76
|
+
bump_type = commit[:bump]
|
60
77
|
if bump_type == :major
|
61
78
|
return :major
|
62
79
|
elsif bump_type == :minor
|
@@ -69,29 +86,26 @@ module Fastlane
|
|
69
86
|
return result
|
70
87
|
end
|
71
88
|
|
72
|
-
def self.
|
73
|
-
|
74
|
-
|
75
|
-
unless allowed_types.include?(match[:type].to_sym)
|
76
|
-
UI.important("Commit #{commit.sha} has invalid type: #{match[:type]}. Ignoring")
|
77
|
-
break
|
78
|
-
end
|
89
|
+
def self.group_commits(commits:, allowed_types:)
|
90
|
+
result = allowed_types.to_h { |type| [type, []] }
|
91
|
+
result[:none] = []
|
79
92
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
body: match[:body],
|
85
|
-
breaking: match[:breaking] ? match[:subject] : nil,
|
86
|
-
original_message: commit.message
|
87
|
-
}
|
93
|
+
commits.each do |commit|
|
94
|
+
if commit[:breaking] && allowed_types.include?(:breaking)
|
95
|
+
result[:breaking] << commit
|
96
|
+
end
|
88
97
|
|
89
|
-
|
90
|
-
|
98
|
+
if commit[:major] && !allowed_types.include?(commit[:type])
|
99
|
+
result[:none] << commit
|
100
|
+
next
|
91
101
|
end
|
92
102
|
|
93
|
-
|
103
|
+
next unless allowed_types.include?(commit[:type])
|
104
|
+
|
105
|
+
result[commit[:type]] << commit
|
94
106
|
end
|
107
|
+
|
108
|
+
return result
|
95
109
|
end
|
96
110
|
|
97
111
|
def self.increase_version(current_version:, bump_type:)
|
@@ -123,7 +137,7 @@ module Fastlane
|
|
123
137
|
grouped_commits.each do |key, section_commits|
|
124
138
|
next unless section_commits.any?
|
125
139
|
|
126
|
-
lines << "### #{type_map[key]}:"
|
140
|
+
lines << "### #{type_map[key]}:" if key != :none
|
127
141
|
lines << ""
|
128
142
|
|
129
143
|
section_commits.each do |commit|
|