fastlane-plugin-semantic_release 1.19.1 → 1.19.4

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: 28a273aa51b74e1a6013f2dd035a6db0d83cabec6f3f07c3bd59c92f426d2f67
4
- data.tar.gz: 5c7e9fc6c6bbb295b1689334c94f2e41ac0010ab53292516380b41fae3a9fc40
3
+ metadata.gz: 01b27d55095447fde70e3e0d4c0ca215b7473cb123723e01e6022d5a55e065a0
4
+ data.tar.gz: 6d7b82296bad8e5d3655f8d428df731f3aaae1aa89ba12bd3e23b2183cafbeaa
5
5
  SHA512:
6
- metadata.gz: 1ad7a7cc60d18602ae2bf76923fe1ab4a44435be39b4ba9db8845e47c7f7a10cb072104cbf5fda822268bd555bb75d9f0d09353b3dfded009bf7a92029f3b4d7
7
- data.tar.gz: a6be6f39ded93ba158942e5e301c17b0c9873995be2f0ad0f69e0fd7e980e07212972fa86c33c0f1ca42328c1f751a5dbe1ba98cbbc4485a56b656a95e9880aa
6
+ metadata.gz: c031c797fd3b19df15f029dd09e17913b2d001b10ef1cd1ac89ccc12ac3b624d43139d3dba7a9a0cea8e35e3d883086c20332d78b8a255109ac1d90e2d1a3fe7
7
+ data.tar.gz: 33ceab41c2c7a0a192402c0dcd019fcf25346d3b65c3bf30f4f1f0cb5269da889c5be4a28b137cb5e646d60420890713dc4a258286d5e466f1d3797fdef3aa71
@@ -19,7 +19,6 @@ module Fastlane
19
19
 
20
20
  class AnalyzeCommitsAction < Action
21
21
  def self.get_last_tag(params)
22
- # Try to find the tag
23
22
  command = "git describe --tags --match=#{params[:match]}"
24
23
  Actions.sh(command, log: params[:debug])
25
24
  rescue StandardError
@@ -42,29 +41,23 @@ module Fastlane
42
41
  end
43
42
 
44
43
  def self.get_beginning_of_next_sprint(params)
45
- # command to get first commit
46
44
  git_command = "git rev-list --max-parents=0 HEAD"
47
-
48
45
  tag = get_last_tag(match: params[:match], debug: params[:debug])
49
46
 
50
- # if tag doesn't exist it get's first commit or fallback tag (v*.*.*)
51
47
  if tag.empty?
52
48
  UI.message("It couldn't match tag for #{params[:match]}. Check if first commit can be taken as a beginning of next release")
53
- # If there is no tag found we taking the first commit of current branch
54
49
  # Use tail -n 1 to handle repos with multiple root commits (e.g. merged histories)
55
- UI.message("First commit of the branch is taken as a begining of next release")
50
+ UI.message("First commit of the branch is taken as a beginning of next release")
56
51
  return {
57
52
  hash: Actions.sh("#{git_command} | tail -n 1", log: params[:debug]).chomp
58
53
  }
59
54
  end
60
55
 
61
- # Tag's format is v2.3.4-5-g7685948
62
- # See git describe man page for more info
63
- # It can be also v2.3.4-5 if there is no commit after tag
64
- tag_name = tag
65
- if tag.split('-').length >= 3
66
- tag_name = tag.split('-')[0...-2].join('-').strip
67
- end
56
+ # git describe appends -<N>-g<hash> when HEAD is ahead of a tag.
57
+ # Use a regex to strip this specific suffix rather than splitting on
58
+ # dashes, which breaks when the tag itself contains dashes (e.g. v1.0.0-beta).
59
+ tag_name = tag.strip
60
+ tag_name = tag_name.sub(/-\d+-g[0-9a-f]+$/, '')
68
61
  parsed_version = tag_name.match(params[:tag_version_match])
69
62
 
70
63
  if parsed_version.nil?
@@ -72,18 +65,23 @@ module Fastlane
72
65
  end
73
66
 
74
67
  version = parsed_version[0]
75
- # Get a hash of last version tag
76
- hash = get_last_tag_hash(
77
- tag_name: tag_name,
78
- debug: params[:debug]
79
- )
68
+ hash = get_last_tag_hash(tag_name: tag_name, debug: params[:debug])
80
69
 
81
70
  UI.message("Found a tag #{tag_name} associated with version #{version}")
82
71
 
83
- return {
84
- hash: hash,
85
- version: version
86
- }
72
+ { hash: hash, version: version }
73
+ end
74
+
75
+ def self.bump_version(major, minor, patch, commit)
76
+ if commit[:release] == "major" || commit[:is_breaking_change]
77
+ [major + 1, 0, 0]
78
+ elsif commit[:release] == "minor"
79
+ [major, minor + 1, 0]
80
+ elsif commit[:release] == "patch"
81
+ [major, minor, patch + 1]
82
+ else
83
+ [major, minor, patch]
84
+ end
87
85
  end
88
86
 
89
87
  def self.clamp_version(next_major, next_minor, next_patch, base_major, base_minor, base_patch)
@@ -99,52 +97,37 @@ module Fastlane
99
97
  end
100
98
 
101
99
  def self.is_releasable(params)
102
- # Hash of the commit where is the last version
103
100
  beginning = get_beginning_of_next_sprint(params)
104
101
 
105
102
  unless beginning
106
- UI.error('It could not find a begining of this sprint. How to fix this:')
103
+ UI.error('It could not find a beginning of this sprint. How to fix this:')
107
104
  UI.error('-- ensure there is only one commit with --max-parents=0 (this command should return one line: "git rev-list --max-parents=0 HEAD")')
108
- UI.error('-- tell us explicitely where the release starts by adding tag like this: vX.Y.Z (where X.Y.Z is version from which it starts computing next version number)')
105
+ UI.error('-- tell us explicitly where the release starts by adding tag like this: vX.Y.Z (where X.Y.Z is version from which it starts computing next version number)')
109
106
  return false
110
107
  end
111
108
 
112
- # Default last version
113
109
  version = beginning[:version] || '0.0.0'
114
- # If the tag is not found we are taking HEAD as reference
115
110
  hash = beginning[:hash] || 'HEAD'
116
111
 
117
- # converts last version string to the int numbers
118
- next_major = (version.split('.')[0] || 0).to_i
119
- next_minor = (version.split('.')[1] || 0).to_i
120
- next_patch = (version.split('.')[2] || 0).to_i
121
-
122
- # Save base version for potential clamping
112
+ next_major, next_minor, next_patch = Helper::SemanticReleaseHelper.parse_semver(version)
123
113
  base_major = next_major
124
114
  base_minor = next_minor
125
115
  base_patch = next_patch
126
116
 
127
117
  is_next_version_compatible_with_codepush = true
128
118
 
129
- # Get commits log between last version and head
130
- splitted = get_commits_from_hash(
131
- hash: hash,
132
- debug: params[:debug]
133
- )
134
-
135
- UI.message("Found #{splitted.length} commits since last release")
136
- releases = params[:releases]
119
+ commits = get_commits_from_hash(hash: hash, debug: params[:debug])
120
+ UI.message("Found #{commits.length} commits since last release")
137
121
 
138
122
  format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
139
- splitted.each do |line|
123
+ commits.each do |line|
140
124
  parts = line.split("|")
141
125
  subject = parts[0].to_s.strip
142
- # conventional commits are in format
143
- # type: subject (fix: app crash - for example)
126
+
144
127
  commit = Helper::SemanticReleaseHelper.parse_commit(
145
128
  commit_subject: subject,
146
129
  commit_body: parts[1],
147
- releases: releases,
130
+ releases: params[:releases],
148
131
  pattern: format_pattern
149
132
  )
150
133
 
@@ -154,41 +137,25 @@ module Fastlane
154
137
  ignore_scopes: params[:ignore_scopes]
155
138
  )
156
139
 
157
- if commit[:release] == "major" || commit[:is_breaking_change]
158
- next_major += 1
159
- next_minor = 0
160
- next_patch = 0
161
- elsif commit[:release] == "minor"
162
- next_minor += 1
163
- next_patch = 0
164
- elsif commit[:release] == "patch"
165
- next_patch += 1
166
- end
167
-
168
- unless commit[:is_codepush_friendly]
169
- is_next_version_compatible_with_codepush = false
170
- end
140
+ next_major, next_minor, next_patch = bump_version(next_major, next_minor, next_patch, commit)
141
+ is_next_version_compatible_with_codepush = false unless commit[:is_codepush_friendly]
171
142
 
172
143
  next_version = "#{next_major}.#{next_minor}.#{next_patch}"
173
144
  UI.message("#{next_version}: #{subject}") if params[:show_version_path]
174
145
  end
175
146
 
176
- # When bump_per_commit is false, clamp to single increment
177
147
  unless params[:bump_per_commit]
178
148
  next_major, next_minor, next_patch = clamp_version(next_major, next_minor, next_patch, base_major, base_minor, base_patch)
179
149
  end
180
150
 
181
151
  next_version = "#{next_major}.#{next_minor}.#{next_patch}"
182
-
183
152
  is_next_version_releasable = Helper::SemanticReleaseHelper.semver_gt(next_version, version)
184
153
 
185
154
  Actions.lane_context[SharedValues::RELEASE_ANALYZED] = true
186
155
  Actions.lane_context[SharedValues::RELEASE_IS_NEXT_VERSION_HIGHER] = is_next_version_releasable
187
156
  Actions.lane_context[SharedValues::RELEASE_IS_NEXT_VERSION_COMPATIBLE_WITH_CODEPUSH] = is_next_version_compatible_with_codepush
188
- # Last release analysis
189
157
  Actions.lane_context[SharedValues::RELEASE_LAST_TAG_HASH] = hash
190
158
  Actions.lane_context[SharedValues::RELEASE_LAST_VERSION] = version
191
- # Next release analysis
192
159
  Actions.lane_context[SharedValues::RELEASE_NEXT_MAJOR_VERSION] = next_major
193
160
  Actions.lane_context[SharedValues::RELEASE_NEXT_MINOR_VERSION] = next_minor
194
161
  Actions.lane_context[SharedValues::RELEASE_NEXT_PATCH_VERSION] = next_patch
@@ -202,47 +169,30 @@ module Fastlane
202
169
 
203
170
  def self.is_codepush_friendly(params)
204
171
  git_command = "git rev-list --max-parents=0 HEAD"
205
- # Begining of the branch is taken for codepush analysis
206
172
  # Use tail -n 1 to handle repos with multiple root commits (e.g. merged histories)
207
173
  hash = Actions.sh("#{git_command} | tail -n 1", log: params[:debug]).chomp
208
174
  next_major = 0
209
175
  next_minor = 0
210
176
  next_patch = 0
211
- base_major = next_major
212
- base_minor = next_minor
213
- base_patch = next_patch
177
+ base_major = 0
178
+ base_minor = 0
179
+ base_patch = 0
214
180
  last_incompatible_codepush_version = '0.0.0'
215
181
 
216
- # Get commits log between last version and head
217
- splitted = get_commits_from_hash(
218
- hash: hash,
219
- debug: params[:debug]
220
- )
221
- releases = params[:releases]
222
- codepush_friendly = params[:codepush_friendly]
182
+ commits = get_commits_from_hash(hash: hash, debug: params[:debug])
223
183
 
224
184
  format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
225
- splitted.each do |line|
226
- # conventional commits are in format
227
- # type: subject (fix: app crash - for example)
185
+ commits.each do |line|
186
+ parts = line.split("|")
228
187
  commit = Helper::SemanticReleaseHelper.parse_commit(
229
- commit_subject: line.split("|")[0],
230
- commit_body: line.split("|")[1],
231
- releases: releases,
188
+ commit_subject: parts[0],
189
+ commit_body: parts[1],
190
+ releases: params[:releases],
232
191
  pattern: format_pattern,
233
- codepush_friendly: codepush_friendly
192
+ codepush_friendly: params[:codepush_friendly]
234
193
  )
235
194
 
236
- if commit[:release] == "major" || commit[:is_breaking_change]
237
- next_major += 1
238
- next_minor = 0
239
- next_patch = 0
240
- elsif commit[:release] == "minor"
241
- next_minor += 1
242
- next_patch = 0
243
- elsif commit[:release] == "patch"
244
- next_patch += 1
245
- end
195
+ next_major, next_minor, next_patch = bump_version(next_major, next_minor, next_patch, commit)
246
196
 
247
197
  unless commit[:is_codepush_friendly]
248
198
  last_incompatible_codepush_version = "#{next_major}.#{next_minor}.#{next_patch}"
@@ -268,7 +218,7 @@ module Fastlane
268
218
  #####################################################
269
219
 
270
220
  def self.description
271
- "Finds a tag of last release and determinates version of next release"
221
+ "Finds a tag of last release and determines version of next release"
272
222
  end
273
223
 
274
224
  def self.details
@@ -276,9 +226,6 @@ module Fastlane
276
226
  end
277
227
 
278
228
  def self.available_options
279
- # Define all options your action supports.
280
-
281
- # Below a few examples
282
229
  [
283
230
  FastlaneCore::ConfigItem.new(
284
231
  key: :match,
@@ -372,11 +319,9 @@ module Fastlane
372
319
  end
373
320
 
374
321
  def self.output
375
- # Define the shared values you are going to provide
376
- # Example
377
322
  [
378
323
  ['RELEASE_ANALYZED', 'True if commits were analyzed.'],
379
- ['RELEASE_IS_NEXT_VERSION_HIGHER', 'True if next version is higher then last version'],
324
+ ['RELEASE_IS_NEXT_VERSION_HIGHER', 'True if next version is higher than last version'],
380
325
  ['RELEASE_IS_NEXT_VERSION_COMPATIBLE_WITH_CODEPUSH', 'True if next version is compatible with codepush'],
381
326
  ['RELEASE_LAST_TAG_HASH', 'Hash of commit that is tagged as a last version'],
382
327
  ['RELEASE_LAST_VERSION', 'Last version number - parsed from last tag.'],
@@ -390,17 +335,14 @@ module Fastlane
390
335
  end
391
336
 
392
337
  def self.return_value
393
- # If your method provides a return value, you can describe here what it does
394
- "Returns true if the next version is higher then the last version"
338
+ "Returns true if the next version is higher than the last version"
395
339
  end
396
340
 
397
341
  def self.authors
398
- # So no one will ever forget your contribution to fastlane :) You are awesome btw!
399
342
  ["xotahal"]
400
343
  end
401
344
 
402
345
  def self.is_supported?(platform)
403
- # you can do things like
404
346
  true
405
347
  end
406
348
  end
@@ -17,168 +17,115 @@ module Fastlane
17
17
  end
18
18
 
19
19
  def self.run(params)
20
- # Get next version number from shared values
21
20
  analyzed = lane_context[SharedValues::RELEASE_ANALYZED]
22
21
 
23
- # If analyze commits action was not run there will be no version in shared
24
- # values. We need to run the action to get next version number
25
22
  unless analyzed
26
23
  UI.user_error!("Release hasn't been analyzed yet. Run analyze_commits action first please.")
27
- # version = other_action.analyze_commits(match: params[:match])
28
24
  end
29
25
 
30
26
  last_tag_hash = lane_context[SharedValues::RELEASE_LAST_TAG_HASH]
31
27
  version = lane_context[SharedValues::RELEASE_NEXT_VERSION]
32
28
 
33
- # Get commits log between last version and head
34
- commits = get_commits_from_hash(
35
- hash: last_tag_hash,
36
- debug: params[:debug]
37
- )
29
+ commits = get_commits_from_hash(hash: last_tag_hash, debug: params[:debug])
38
30
  parsed = parse_commits(commits, params)
39
31
 
40
- commit_url = params[:commit_url]
41
- format = params[:format]
42
-
43
- note_builder(format, parsed, version, commit_url, params)
32
+ note_builder(params[:format], parsed, version, params[:commit_url], params)
44
33
  end
45
34
 
46
35
  def self.note_builder(format, commits, version, commit_url, params)
47
36
  sections = params[:sections]
48
-
49
37
  result = ""
50
38
 
51
- # Begining of release notes
52
39
  if params[:display_title] == true
53
40
  title = version
54
41
  title += " #{params[:title]}" if params[:title]
55
42
  title += " (#{Date.today})"
56
43
 
57
- result = style_text(title, format, "title").to_s
58
- result += "\n\n"
44
+ result = "#{style_text(title, format, 'title')}\n\n"
59
45
  end
60
46
 
61
47
  params[:order].each do |type|
62
- # write section only if there is at least one commit
63
48
  next if commits.none? { |commit| commit[:type] == type }
64
49
 
65
- result += style_text(sections[type.to_sym], format, "heading").to_s
66
- result += "\n"
50
+ result += "#{style_text(sections[type.to_sym], format, 'heading')}\n"
67
51
 
68
52
  commits.each do |commit|
69
53
  next if commit[:type] != type || commit[:is_merge]
70
54
 
71
55
  result += "-"
72
-
73
- unless commit[:scope].nil?
74
- formatted_text = style_text("#{commit[:scope]}:", format, "bold").to_s
75
- result += " #{formatted_text}"
76
- end
77
-
56
+ result += " #{style_text("#{commit[:scope]}:", format, 'bold')}" unless commit[:scope].nil?
78
57
  result += " #{commit[:subject]}"
79
-
80
- if params[:display_links] == true
81
- styled_link = build_commit_link(commit, commit_url, format).to_s
82
- result += " (#{styled_link})"
83
- end
84
-
85
- if params[:display_author]
86
- result += " - #{commit[:author_name]}"
87
- end
88
-
58
+ result += " (#{build_commit_link(commit, commit_url, format)})" if params[:display_links] == true
59
+ result += " - #{commit[:author_name]}" if params[:display_author]
89
60
  result += "\n"
90
61
  end
91
62
  result += "\n"
92
63
  end
93
64
 
94
65
  if commits.any? { |commit| commit[:is_breaking_change] == true }
95
- result += style_text("BREAKING CHANGES", format, "heading").to_s
96
- result += "\n"
66
+ result += "#{style_text('BREAKING CHANGES', format, 'heading')}\n"
97
67
 
98
68
  commits.each do |commit|
99
69
  next unless commit[:is_breaking_change]
100
70
 
101
- result += "- #{commit[:breaking_change]}" # This is the only unique part of this loop
102
-
103
- if params[:display_links] == true
104
- styled_link = build_commit_link(commit, commit_url, format).to_s
105
- result += " (#{styled_link})"
106
- end
107
-
108
- if params[:display_author]
109
- result += " - #{commit[:author_name]}"
110
- end
111
-
71
+ result += "- #{commit[:breaking_change]}"
72
+ result += " (#{build_commit_link(commit, commit_url, format)})" if params[:display_links] == true
73
+ result += " - #{commit[:author_name]}" if params[:display_author]
112
74
  result += "\n"
113
75
  end
114
76
 
115
77
  result += "\n"
116
78
  end
117
79
 
118
- # Trim any trailing newlines
119
80
  result.rstrip!
120
81
  end
121
82
 
122
83
  def self.style_text(text, format, style)
123
- # formats the text according to the style we're looking to use
124
-
125
- # Skips all styling
126
84
  case style
127
85
  when "title"
128
- if format == "markdown"
129
- "# #{text}"
130
- elsif format == "slack"
131
- "*#{text}*"
132
- else
133
- text
86
+ case format
87
+ when "markdown" then "# #{text}"
88
+ when "slack" then "*#{text}*"
89
+ else text
134
90
  end
135
91
  when "heading"
136
- if format == "markdown"
137
- "### #{text}"
138
- elsif format == "slack"
139
- "*#{text}*"
140
- else
141
- "#{text}:"
92
+ case format
93
+ when "markdown" then "### #{text}"
94
+ when "slack" then "*#{text}*"
95
+ else "#{text}:"
142
96
  end
143
97
  when "bold"
144
- if format == "markdown"
145
- "**#{text}**"
146
- elsif format == "slack"
147
- "*#{text}*"
148
- else
149
- text
98
+ case format
99
+ when "markdown" then "**#{text}**"
100
+ when "slack" then "*#{text}*"
101
+ else text
150
102
  end
151
103
  else
152
- text # catchall, shouldn't be needed
104
+ text
153
105
  end
154
106
  end
155
107
 
156
108
  def self.build_commit_link(commit, commit_url, format)
157
- # formats the link according to the output format we need
158
109
  short_hash = commit[:short_hash]
159
- hash = commit[:hash]
160
- url = "#{commit_url}/#{hash}"
110
+ url = "#{commit_url}/#{commit[:hash]}"
161
111
 
162
112
  case format
163
- when "slack"
164
- "<#{url}|#{short_hash}>"
165
- when "markdown"
166
- "[#{short_hash}](#{url})"
167
- else
168
- url
113
+ when "slack" then "<#{url}|#{short_hash}>"
114
+ when "markdown" then "[#{short_hash}](#{url})"
115
+ else url
169
116
  end
170
117
  end
171
118
 
172
119
  def self.parse_commits(commits, params)
173
120
  parsed = []
174
- # %s|%b|%H|%h|%an|%at
175
121
  format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
122
+
176
123
  commits.each do |line|
177
- splitted = line.split("|")
124
+ parts = line.split("|")
178
125
 
179
126
  commit = Helper::SemanticReleaseHelper.parse_commit(
180
- commit_subject: splitted[0],
181
- commit_body: splitted[1],
127
+ commit_subject: parts[0],
128
+ commit_body: parts[1],
182
129
  pattern: format_pattern
183
130
  )
184
131
 
@@ -188,10 +135,10 @@ module Fastlane
188
135
  ignore_scopes: params[:ignore_scopes]
189
136
  )
190
137
 
191
- commit[:hash] = splitted[2]
192
- commit[:short_hash] = splitted[3]
193
- commit[:author_name] = splitted[4]
194
- commit[:commit_date] = splitted[5]
138
+ commit[:hash] = parts[2]
139
+ commit[:short_hash] = parts[3]
140
+ commit[:author_name] = parts[4]
141
+ commit[:commit_date] = parts[5]
195
142
 
196
143
  parsed.push(commit)
197
144
  end
@@ -212,9 +159,6 @@ module Fastlane
212
159
  end
213
160
 
214
161
  def self.available_options
215
- # Define all options your action supports.
216
-
217
- # Below a few examples
218
162
  [
219
163
  FastlaneCore::ConfigItem.new(
220
164
  key: :format,
@@ -301,23 +245,18 @@ module Fastlane
301
245
  end
302
246
 
303
247
  def self.output
304
- # Define the shared values you are going to provide
305
- # Example
306
248
  []
307
249
  end
308
250
 
309
251
  def self.return_value
310
- # If your method provides a return value, you can describe here what it does
311
252
  "Returns generated release notes as a string"
312
253
  end
313
254
 
314
255
  def self.authors
315
- # So no one will ever forget your contribution to fastlane :) You are awesome btw!
316
256
  ["xotahal"]
317
257
  end
318
258
 
319
259
  def self.is_supported?(platform)
320
- # you can do things like
321
260
  true
322
261
  end
323
262
  end
@@ -5,16 +5,20 @@ module Fastlane
5
5
 
6
6
  module Helper
7
7
  class SemanticReleaseHelper
8
+ FORMAT_PATTERNS = {
9
+ "default" => /^(docs|fix|feat|chore|style|refactor|perf|test)(?:\((.*)\))?(!?): (.*)/i,
10
+ "angular" => /^(\w*)(?:\((.*)\))?(): (.*)/
11
+ }.freeze
12
+
8
13
  def self.format_patterns
9
- return {
10
- "default" => /^(docs|fix|feat|chore|style|refactor|perf|test)(?:\((.*)\))?(!?): (.*)/i,
11
- "angular" => /^(\w*)(?:\((.*)\))?(): (.*)/
12
- }
14
+ FORMAT_PATTERNS
15
+ end
16
+
17
+ def self.parse_semver(version_string)
18
+ parts = version_string.split('.')
19
+ [(parts[0] || 0).to_i, (parts[1] || 0).to_i, (parts[2] || 0).to_i]
13
20
  end
14
21
 
15
- # class methods that you define here become available in your action
16
- # as `Helper::SemanticReleaseHelper.your_method`
17
- #
18
22
  def self.git_log(params)
19
23
  command = "git log --pretty='#{params[:pretty]}' --reverse #{params[:start]}..HEAD"
20
24
  Actions.sh(command, log: params[:debug]).chomp
@@ -25,13 +29,10 @@ module Fastlane
25
29
  scopes_to_include = params[:include_scopes]
26
30
  scopes_to_ignore = params[:ignore_scopes]
27
31
 
28
- unless scopes_to_include.empty?
29
- return !scopes_to_include.include?(commit_scope)
30
- end
32
+ return !scopes_to_include.include?(commit_scope) unless scopes_to_include.empty?
33
+ return scopes_to_ignore.include?(commit_scope) unless commit_scope.nil?
31
34
 
32
- unless commit_scope.nil?
33
- return scopes_to_ignore.include?(commit_scope)
34
- end
35
+ false
35
36
  end
36
37
 
37
38
  def self.parse_commit(params)
@@ -40,8 +41,6 @@ module Fastlane
40
41
  releases = params[:releases]
41
42
  codepush_friendly = params[:codepush_friendly]
42
43
  pattern = params[:pattern]
43
- breaking_change_pattern = /BREAKING CHANGES?: (.*)/
44
- codepush_pattern = /codepush?: (.*)/
45
44
 
46
45
  matched = commit_subject.match(pattern)
47
46
  result = {
@@ -51,67 +50,39 @@ module Fastlane
51
50
  type: 'no_type'
52
51
  }
53
52
 
54
- unless matched.nil?
55
- type = matched[1].downcase
56
- scope = matched[2]
53
+ return result if matched.nil?
57
54
 
58
- result[:is_valid] = true
59
- result[:type] = type
60
- result[:scope] = scope
61
- result[:has_exclamation_mark] = matched[3] == '!'
62
- result[:subject] = matched[4]
63
-
64
- unless releases.nil?
65
- result[:release] = releases[type.to_sym]
66
- end
67
- unless codepush_friendly.nil?
68
- result[:is_codepush_friendly] = codepush_friendly.include?(type)
69
- end
55
+ type = matched[1].downcase
56
+ result[:is_valid] = true
57
+ result[:type] = type
58
+ result[:scope] = matched[2]
59
+ result[:has_exclamation_mark] = matched[3] == '!'
60
+ result[:subject] = matched[4]
70
61
 
71
- unless commit_body.nil?
72
- breaking_change_matched = commit_body.match(breaking_change_pattern)
73
- codepush_matched = commit_body.match(codepush_pattern)
74
-
75
- unless breaking_change_matched.nil?
76
- result[:is_breaking_change] = true
77
- result[:breaking_change] = breaking_change_matched[1]
78
- end
79
- unless codepush_matched.nil?
80
- result[:is_codepush_friendly] = codepush_matched[1] == 'ok'
81
- end
82
- end
62
+ if result[:has_exclamation_mark]
63
+ result[:is_breaking_change] = true
64
+ result[:breaking_change] = matched[4]
83
65
  end
84
66
 
85
- result
86
- end
67
+ result[:release] = releases[type.to_sym] unless releases.nil?
68
+ result[:is_codepush_friendly] = codepush_friendly.include?(type) unless codepush_friendly.nil?
87
69
 
88
- def self.semver_gt(first, second)
89
- first_major = (first.split('.')[0] || 0).to_i
90
- first_minor = (first.split('.')[1] || 0).to_i
91
- first_patch = (first.split('.')[2] || 0).to_i
92
-
93
- second_major = (second.split('.')[0] || 0).to_i
94
- second_minor = (second.split('.')[1] || 0).to_i
95
- second_patch = (second.split('.')[2] || 0).to_i
96
-
97
- # Check if next version is higher then last version
98
- if first_major > second_major
99
- return true
100
- elsif first_major == second_major
101
- if first_minor > second_minor
102
- return true
103
- elsif first_minor == second_minor
104
- if first_patch > second_patch
105
- return true
106
- end
70
+ unless commit_body.nil?
71
+ breaking_match = commit_body.match(/BREAKING CHANGES?: (.*)/)
72
+ codepush_match = commit_body.match(/codepush?: (.*)/)
73
+
74
+ if breaking_match
75
+ result[:is_breaking_change] = true
76
+ result[:breaking_change] = breaking_match[1]
107
77
  end
78
+ result[:is_codepush_friendly] = (codepush_match[1] == 'ok') if codepush_match
108
79
  end
109
80
 
110
- return false
81
+ result
111
82
  end
112
83
 
113
- def self.semver_lt(first, second)
114
- return !semver_gt(first, second)
84
+ def self.semver_gt(first, second)
85
+ (parse_semver(first) <=> parse_semver(second)) == 1
115
86
  end
116
87
  end
117
88
  end
@@ -1 +1 @@
1
- module Fastlane module SemanticRelease VERSION = "1.19.1" end end
1
+ module Fastlane module SemanticRelease VERSION = "1.19.4" end end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-semantic_release
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.1
4
+ version: 1.19.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiří Otáhal