fastlane-plugin-semantic_release 1.8.0 → 1.12.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: 991694d09785835a5aee8a33b9d53ba0d30294942a13abbb5611a6a82b45022f
4
- data.tar.gz: a65c5eb20db107b72792baad5bcf6e3e49629703f878cd0228530a2c892f48c8
3
+ metadata.gz: 801ae7e90c09769c435f3aa1640323338ff7b343d3005427208f371f2cd06711
4
+ data.tar.gz: '0790c9a548fd4d4bd59409bf659b488af3db65cfb098683dac62658b36b866c4'
5
5
  SHA512:
6
- metadata.gz: 9d71f3cb33ac74a94a761a48d72ca42acd3babc5d9d8234352346bd56dd55ad4d79685be372f2c1e1d9ec834947ec53074fcd66146381a80d26b10870b3bdb58
7
- data.tar.gz: b32097e494de9908a958039e115dfdff3e1cbc9a2d9f26bf59099cbc5803fa8bc998c776517a72978410056f8d9ceaec2c653936c3142ecd6b42f66e7c87ca94
6
+ metadata.gz: c8527660760ffa383de7ff51baa708323da17ed33a7d601becc88375f4ad789ee6d4b99970995b42ae010a6a8f976b661fd53c22dd522bef8d0df30d3fc091bd
7
+ data.tar.gz: 6935fab5c02ffa2cb63d6d5fde4a7012e4abd800263059265c75c2f29155d179af8a960e11ebb146a329cc6c7af44ae52dc8718da04ba1b7309a566fc80767c8
@@ -13,13 +13,14 @@ module Fastlane
13
13
  RELEASE_NEXT_PATCH_VERSION = :RELEASE_NEXT_PATCH_VERSION
14
14
  RELEASE_NEXT_VERSION = :RELEASE_NEXT_VERSION
15
15
  RELEASE_LAST_INCOMPATIBLE_CODEPUSH_VERSION = :RELEASE_LAST_INCOMPATIBLE_CODEPUSH_VERSION
16
+ CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN = :CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN
16
17
  end
17
18
 
18
19
  class AnalyzeCommitsAction < Action
19
20
  def self.get_last_tag(params)
20
21
  # Try to find the tag
21
22
  command = "git describe --tags --match=#{params[:match]}"
22
- Actions.sh(command, log: false)
23
+ Actions.sh(command, log: params[:debug])
23
24
  rescue
24
25
  UI.message("Tag was not found for match pattern - #{params[:match]}")
25
26
  ''
@@ -27,11 +28,15 @@ module Fastlane
27
28
 
28
29
  def self.get_last_tag_hash(params)
29
30
  command = "git rev-list -n 1 refs/tags/#{params[:tag_name]}"
30
- Actions.sh(command, log: false).chomp
31
+ Actions.sh(command, log: params[:debug]).chomp
31
32
  end
32
33
 
33
34
  def self.get_commits_from_hash(params)
34
- commits = Helper::SemanticReleaseHelper.git_log('%s|%b|>', params[:hash])
35
+ commits = Helper::SemanticReleaseHelper.git_log(
36
+ pretty: '%s|%b|>',
37
+ start: params[:hash],
38
+ debug: params[:debug]
39
+ )
35
40
  commits.split("|>")
36
41
  end
37
42
 
@@ -42,16 +47,19 @@ module Fastlane
42
47
  # Default last version
43
48
  version = '0.0.0'
44
49
 
45
- tag = get_last_tag(match: params[:match])
50
+ tag = get_last_tag(
51
+ match: params[:match],
52
+ debug: params[:debug]
53
+ )
46
54
 
47
55
  if tag.empty?
48
56
  UI.message("First commit of the branch is taken as a begining of next release")
49
57
  # If there is no tag found we taking the first commit of current branch
50
- hash = Actions.sh('git rev-list --max-parents=0 HEAD', log: false).chomp
58
+ hash = Actions.sh('git rev-list --max-parents=0 HEAD', log: params[:debug]).chomp
51
59
  else
52
60
  # Tag's format is v2.3.4-5-g7685948
53
61
  # See git describe man page for more info
54
- tag_name = tag.split('-')[0].strip
62
+ tag_name = tag.split('-')[0...-2].join('-').strip
55
63
  parsed_version = tag_name.match(params[:tag_version_match])
56
64
 
57
65
  if parsed_version.nil?
@@ -60,7 +68,10 @@ module Fastlane
60
68
 
61
69
  version = parsed_version[0]
62
70
  # Get a hash of last version tag
63
- hash = get_last_tag_hash(tag_name: tag_name)
71
+ hash = get_last_tag_hash(
72
+ tag_name: tag_name,
73
+ debug: params[:debug]
74
+ )
64
75
 
65
76
  UI.message("Found a tag #{tag_name} associated with version #{version}")
66
77
  end
@@ -71,18 +82,25 @@ module Fastlane
71
82
  next_patch = (version.split('.')[2] || 0).to_i
72
83
 
73
84
  # Get commits log between last version and head
74
- splitted = get_commits_from_hash(hash: hash)
85
+ splitted = get_commits_from_hash(
86
+ hash: hash,
87
+ debug: params[:debug]
88
+ )
75
89
 
76
90
  UI.message("Found #{splitted.length} commits since last release")
77
91
  releases = params[:releases]
78
92
 
93
+ format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
79
94
  splitted.each do |line|
95
+ parts = line.split("|")
96
+ subject = parts[0].strip
80
97
  # conventional commits are in format
81
98
  # type: subject (fix: app crash - for example)
82
99
  commit = Helper::SemanticReleaseHelper.parse_commit(
83
- commit_subject: line.split("|")[0],
84
- commit_body: line.split("|")[1],
85
- releases: releases
100
+ commit_subject: subject,
101
+ commit_body: parts[1],
102
+ releases: releases,
103
+ pattern: format_pattern
86
104
  )
87
105
 
88
106
  unless commit[:scope].nil?
@@ -105,7 +123,7 @@ module Fastlane
105
123
  end
106
124
 
107
125
  next_version = "#{next_major}.#{next_minor}.#{next_patch}"
108
- UI.message("#{next_version}: #{line}")
126
+ UI.message("#{next_version}: #{subject}") if params[:show_version_path]
109
127
  end
110
128
 
111
129
  next_version = "#{next_major}.#{next_minor}.#{next_patch}"
@@ -130,18 +148,31 @@ module Fastlane
130
148
  end
131
149
 
132
150
  def self.is_codepush_friendly(params)
151
+ git_command = 'git rev-list --max-parents=0 HEAD'
133
152
  # Begining of the branch is taken for codepush analysis
134
- hash = Actions.sh('git rev-list --max-parents=0 HEAD', log: false).chomp
153
+ hash_lines = Actions.sh("#{git_command} | wc -l", log: params[:debug]).chomp
154
+ hash = Actions.sh(git_command, log: params[:debug]).chomp
135
155
  next_major = 0
136
156
  next_minor = 0
137
157
  next_patch = 0
138
158
  last_incompatible_codepush_version = '0.0.0'
139
159
 
160
+ if hash_lines.to_i > 1
161
+ UI.error("#{git_command} resulted to more than 1 hash")
162
+ UI.error('This usualy happens when you pull only part of a git history. Check out how you pull the repo! "git fetch" should be enough.')
163
+ Actions.sh(git_command, log: true).chomp
164
+ return false
165
+ end
166
+
140
167
  # Get commits log between last version and head
141
- splitted = get_commits_from_hash(hash: hash)
168
+ splitted = get_commits_from_hash(
169
+ hash: hash,
170
+ debug: params[:debug]
171
+ )
142
172
  releases = params[:releases]
143
173
  codepush_friendly = params[:codepush_friendly]
144
174
 
175
+ format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
145
176
  splitted.each do |line|
146
177
  # conventional commits are in format
147
178
  # type: subject (fix: app crash - for example)
@@ -149,6 +180,7 @@ module Fastlane
149
180
  commit_subject: line.split("|")[0],
150
181
  commit_body: line.split("|")[1],
151
182
  releases: releases,
183
+ pattern: format_pattern,
152
184
  codepush_friendly: codepush_friendly
153
185
  )
154
186
 
@@ -202,6 +234,27 @@ module Fastlane
202
234
  UI.user_error!("No match for analyze_commits action given, pass using `match: 'expr'`") unless value && !value.empty?
203
235
  end
204
236
  ),
237
+ FastlaneCore::ConfigItem.new(
238
+ key: :commit_format,
239
+ description: "The commit format to apply. Presets are 'default' or 'angular', or you can provide your own Regexp. Note: the supplied regex _must_ have 4 capture groups, in order: type, scope, has_exclamation_mark, and subject",
240
+ default_value: "default",
241
+ is_string: false,
242
+ verify_block: proc do |value|
243
+ case value
244
+ when String
245
+ unless Helper::SemanticReleaseHelper.format_patterns.key?(value)
246
+ UI.user_error!("Invalid format preset: #{value}")
247
+ end
248
+
249
+ pattern = Helper::SemanticReleaseHelper.format_patterns[value]
250
+ when Regexp
251
+ pattern = value
252
+ else
253
+ UI.user_error!("Invalid option type: #{value.inspect}")
254
+ end
255
+ Actions.lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN] = pattern
256
+ end
257
+ ),
205
258
  FastlaneCore::ConfigItem.new(
206
259
  key: :releases,
207
260
  description: "Map types of commit to release (major, minor, patch)",
@@ -226,6 +279,20 @@ module Fastlane
226
279
  default_value: [],
227
280
  type: Array,
228
281
  optional: true
282
+ ),
283
+ FastlaneCore::ConfigItem.new(
284
+ key: :show_version_path,
285
+ description: "True if you want to print out the version calculated for each commit",
286
+ default_value: true,
287
+ type: Boolean,
288
+ optional: true
289
+ ),
290
+ FastlaneCore::ConfigItem.new(
291
+ key: :debug,
292
+ description: "True if you want to log out a debug info",
293
+ default_value: false,
294
+ type: Boolean,
295
+ optional: true
229
296
  )
230
297
  ]
231
298
  end
@@ -242,7 +309,8 @@ module Fastlane
242
309
  ['RELEASE_NEXT_MINOR_VERSION', 'Minor number of the next version'],
243
310
  ['RELEASE_NEXT_PATCH_VERSION', 'Patch number of the next version'],
244
311
  ['RELEASE_NEXT_VERSION', 'Next version string in format (major.minor.patch)'],
245
- ['RELEASE_LAST_INCOMPATIBLE_CODEPUSH_VERSION', 'Last commit without codepush']
312
+ ['RELEASE_LAST_INCOMPATIBLE_CODEPUSH_VERSION', 'Last commit without codepush'],
313
+ ['CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN', 'The format pattern Regexp used to match commits (mainly for internal use)']
246
314
  ]
247
315
  end
248
316
 
@@ -8,7 +8,11 @@ module Fastlane
8
8
 
9
9
  class ConventionalChangelogAction < Action
10
10
  def self.get_commits_from_hash(params)
11
- commits = Helper::SemanticReleaseHelper.git_log('%s|%b|%H|%h|%an|%at|>', params[:hash])
11
+ commits = Helper::SemanticReleaseHelper.git_log(
12
+ pretty: '%s|%b|%H|%h|%an|%at|>',
13
+ start: params[:hash],
14
+ debug: params[:debug]
15
+ )
12
16
  commits.split("|>")
13
17
  end
14
18
 
@@ -27,7 +31,10 @@ module Fastlane
27
31
  version = lane_context[SharedValues::RELEASE_NEXT_VERSION]
28
32
 
29
33
  # Get commits log between last version and head
30
- commits = get_commits_from_hash(hash: last_tag_hash)
34
+ commits = get_commits_from_hash(
35
+ hash: last_tag_hash,
36
+ debug: params[:debug]
37
+ )
31
38
  parsed = parse_commits(commits)
32
39
 
33
40
  commit_url = params[:commit_url]
@@ -168,12 +175,14 @@ module Fastlane
168
175
  def self.parse_commits(commits)
169
176
  parsed = []
170
177
  # %s|%b|%H|%h|%an|%at
178
+ format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
171
179
  commits.each do |line|
172
180
  splitted = line.split("|")
173
181
 
174
182
  commit = Helper::SemanticReleaseHelper.parse_commit(
175
183
  commit_subject: splitted[0],
176
- commit_body: splitted[1]
184
+ commit_body: splitted[1],
185
+ pattern: format_pattern
177
186
  )
178
187
 
179
188
  commit[:hash] = splitted[2]
@@ -263,6 +272,13 @@ module Fastlane
263
272
  default_value: true,
264
273
  type: Boolean,
265
274
  optional: true
275
+ ),
276
+ FastlaneCore::ConfigItem.new(
277
+ key: :debug,
278
+ description: "True if you want to log out a debug info",
279
+ default_value: false,
280
+ type: Boolean,
281
+ optional: true
266
282
  )
267
283
  ]
268
284
  end
@@ -5,12 +5,19 @@ module Fastlane
5
5
 
6
6
  module Helper
7
7
  class SemanticReleaseHelper
8
+ def self.format_patterns
9
+ return {
10
+ "default" => /^(docs|fix|feat|chore|style|refactor|perf|test)(?:\((.*)\))?(!?)\: (.*)/,
11
+ "angular" => /^(\w*)(?:\((.*)\))?(): (.*)/
12
+ }
13
+ end
14
+
8
15
  # class methods that you define here become available in your action
9
16
  # as `Helper::SemanticReleaseHelper.your_method`
10
17
  #
11
- def self.git_log(pretty, start)
12
- command = "git log --pretty='#{pretty}' --reverse #{start}..HEAD"
13
- Actions.sh(command, log: false).chomp
18
+ def self.git_log(params)
19
+ command = "git log --pretty='#{params[:pretty]}' --reverse #{params[:start]}..HEAD"
20
+ Actions.sh(command, log: params[:debug]).chomp
14
21
  end
15
22
 
16
23
  def self.parse_commit(params)
@@ -18,7 +25,7 @@ module Fastlane
18
25
  commit_body = params[:commit_body]
19
26
  releases = params[:releases]
20
27
  codepush_friendly = params[:codepush_friendly]
21
- pattern = /^(docs|fix|feat|chore|style|refactor|perf|test)(\((.*)\))?(!?)\: (.*)/
28
+ pattern = params[:pattern]
22
29
  breaking_change_pattern = /BREAKING CHANGES?: (.*)/
23
30
  codepush_pattern = /codepush?: (.*)/
24
31
 
@@ -32,13 +39,13 @@ module Fastlane
32
39
 
33
40
  unless matched.nil?
34
41
  type = matched[1]
35
- scope = matched[3]
42
+ scope = matched[2]
36
43
 
37
44
  result[:is_valid] = true
38
45
  result[:type] = type
39
46
  result[:scope] = scope
40
- result[:has_exclamation_mark] = matched[4] == '!'
41
- result[:subject] = matched[5]
47
+ result[:has_exclamation_mark] = matched[3] == '!'
48
+ result[:subject] = matched[4]
42
49
 
43
50
  unless releases.nil?
44
51
  result[:release] = releases[type.to_sym]
@@ -1 +1 @@
1
- module Fastlane module SemanticRelease VERSION = "1.8.0" end end
1
+ module Fastlane module SemanticRelease VERSION = "1.12.0" end end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-semantic_release
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jiří Otáhal
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-13 00:00:00.000000000 Z
11
+ date: 2020-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry