fastlane-plugin-better_semantic_release 1.0.0 → 2.0.2

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: 56cbc72476d971316f6fa98a4a8d761270ea92ee1c1cc07662f0ff0121a123f5
4
- data.tar.gz: 17c1f14c265f83d8fb37c518b5759afbe9a93c7c65de46981bd85bffa70cc765
3
+ metadata.gz: 07acfe8333f8d51d614bf67934dcce916dc921ab6430cf847b733ca9c1720079
4
+ data.tar.gz: 3d06659fa89cb3550264af43d2be11a76bf324d116289d3fa0319f38dd61a298
5
5
  SHA512:
6
- metadata.gz: 65b093fb5a663eb41c29b5fb5194a58e47f0f68c025485d80620f9c5b94ac1f5ad5b9e9d0276d0c7344a0a96517309f8932bc4485870e793ecc84130f82f9ff8
7
- data.tar.gz: e87fd555bcdd5e41da77c6b2febe97132febc31e0b46e39ed45d750ec9b1f617ba91a365f43692922f706ef544286b802922aaa094acbbc28fb1063b9362fdf3
6
+ metadata.gz: 4a6640db9100bde01932fcda01e0f0d918d5c38f923707475f04bb9ff0548b03d1ae54e218b6d1129baffa4ae2357be3e24a5444c4a4a49e9211c4e434881ba6
7
+ data.tar.gz: 7e7f49b2afbfdcb8583fc2fe72dd4b8b97e7b96ad411e3e2c219f55d4c88328f2481d54d7214d621a39b82b816c689b3f810a0da36a7b10e7979bf615ce9b30f
@@ -28,8 +28,16 @@ module Fastlane
28
28
  end
29
29
 
30
30
  def self.get_last_tag_hash(params)
31
- command = "git rev-list -n 1 refs/tags/#{params[:tag_name]}"
32
- Actions.sh(command, log: params[:debug]).chomp
31
+ #command = "git rev-list -n 1 refs/tags/#{params[:tag_name]}"
32
+ #Actions.sh(command, log: params[:debug]).chomp
33
+
34
+ command = "git log -2 --pretty=format:'%H' #{params[:tag_name]}"
35
+ command_output = Actions.sh(command, log: false).chomp
36
+ hashes = command_output.split("\n")
37
+ if hashes.length > 1
38
+ return hashes[1]
39
+ end
40
+ return nil
33
41
  end
34
42
 
35
43
  def self.get_commits_from_hash(params)
@@ -42,15 +50,14 @@ module Fastlane
42
50
  end
43
51
 
44
52
  def self.get_beginning_of_next_sprint(params)
45
- # command to get first commit
46
- git_command = 'git rev-list --max-parents=0 HEAD'
47
-
48
53
  tag = get_last_tag(match: params[:match], debug: params[:debug])
49
54
 
50
55
  # if tag doesn't exist it get's first commit or fallback tag (v*.*.*)
51
56
  if tag.empty?
52
57
  UI.message("It couldn't match tag for #{params[:match]}. Check if first commit can be taken as a beginning of next release")
53
58
  # If there is no tag found we taking the first commit of current branch
59
+ # command to get first commit
60
+ git_command = 'git rev-list --max-parents=0 HEAD'
54
61
  hash_lines = Actions.sh("#{git_command} | wc -l", log: params[:debug]).chomp
55
62
 
56
63
  if hash_lines.to_i == 1
@@ -126,43 +133,44 @@ module Fastlane
126
133
  releases = params[:releases]
127
134
 
128
135
  format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
129
- splitted.each do |line|
130
- parts = line.split("|")
131
- subject = parts[0].strip
132
- # conventional commits are in format
133
- # type: subject (fix: app crash - for example)
134
- commit = Helper::BetterSemanticReleaseHelper.parse_commit(
135
- commit_subject: subject,
136
- commit_body: parts[1],
137
- releases: releases,
138
- pattern: format_pattern
139
- )
136
+ splitted.each do |squashed_commit|
137
+ commits = squashed_commit.split("*")
138
+ commits.drop(1).each do |line|
139
+ # conventional commits are in format
140
+ # type: subject (fix: app crash - for example)
141
+ commit = Helper::BetterSemanticReleaseHelper.parse_commit(
142
+ commit_subject: line,
143
+ commit_body: line.split(":")[1].strip,
144
+ releases: releases,
145
+ pattern: format_pattern
146
+ )
147
+
148
+ unless commit[:scope].nil?
149
+ # if this commit has a scope, then we need to inspect to see if that is one of the scopes we're trying to exclude
150
+ scope = commit[:scope]
151
+ scopes_to_ignore = params[:ignore_scopes]
152
+ # if it is, we'll skip this commit when bumping versions
153
+ next if scopes_to_ignore.include?(scope) #=> true
154
+ end
140
155
 
141
- unless commit[:scope].nil?
142
- # if this commit has a scope, then we need to inspect to see if that is one of the scopes we're trying to exclude
143
- scope = commit[:scope]
144
- scopes_to_ignore = params[:ignore_scopes]
145
- # if it is, we'll skip this commit when bumping versions
146
- next if scopes_to_ignore.include?(scope) #=> true
147
- end
156
+ if commit[:release] == "major" || commit[:is_breaking_change]
157
+ next_major += 1
158
+ next_minor = 0
159
+ next_patch = 0
160
+ elsif commit[:release] == "minor"
161
+ next_minor += 1
162
+ next_patch = 0
163
+ elsif commit[:release] == "patch"
164
+ next_patch += 1
165
+ end
148
166
 
149
- if commit[:release] == "major" || commit[:is_breaking_change]
150
- next_major += 1
151
- next_minor = 0
152
- next_patch = 0
153
- elsif commit[:release] == "minor"
154
- next_minor += 1
155
- next_patch = 0
156
- elsif commit[:release] == "patch"
157
- next_patch += 1
158
- end
167
+ unless commit[:is_codepush_friendly]
168
+ is_next_version_compatible_with_codepush = false
169
+ end
159
170
 
160
- unless commit[:is_codepush_friendly]
161
- is_next_version_compatible_with_codepush = false
171
+ next_version = "#{next_major}.#{next_minor}.#{next_patch}"
172
+ UI.message("#{next_version}: #{subject}") if params[:show_version_path]
162
173
  end
163
-
164
- next_version = "#{next_major}.#{next_minor}.#{next_patch}"
165
- UI.message("#{next_version}: #{subject}") if params[:show_version_path]
166
174
  end
167
175
 
168
176
  next_version = "#{next_major}.#{next_minor}.#{next_patch}"
@@ -188,7 +196,7 @@ module Fastlane
188
196
  end
189
197
 
190
198
  def self.is_codepush_friendly(params)
191
- git_command = 'git rev-list --max-parents=0 HEAD'
199
+ git_command = "git rev-list --max-parents=#{params[:start_hash]} HEAD"
192
200
  # Begining of the branch is taken for codepush analysis
193
201
  hash_lines = Actions.sh("#{git_command} | wc -l", log: params[:debug]).chomp
194
202
  hash = Actions.sh(git_command, log: params[:debug]).chomp
@@ -214,29 +222,34 @@ module Fastlane
214
222
 
215
223
  format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
216
224
  splitted.each do |line|
217
- # conventional commits are in format
218
- # type: subject (fix: app crash - for example)
219
- commit = Helper::BetterSemanticReleaseHelper.parse_commit(
220
- commit_subject: line.split("|")[0],
221
- commit_body: line.split("|")[1],
222
- releases: releases,
223
- pattern: format_pattern,
224
- codepush_friendly: codepush_friendly
225
- )
226
-
227
- if commit[:release] == "major" || commit[:is_breaking_change]
228
- next_major += 1
229
- next_minor = 0
230
- next_patch = 0
231
- elsif commit[:release] == "minor"
232
- next_minor += 1
233
- next_patch = 0
234
- elsif commit[:release] == "patch"
235
- next_patch += 1
236
- end
225
+ parts = line.split(':')
226
+ if parts.length > 1
227
+ # conventional commits are in format
228
+ # type: subject (fix: app crash - for example)
229
+ commit = Helper::BetterSemanticReleaseHelper.parse_commit(
230
+ commit_subject: line,
231
+ commit_body: parts[1].strip,
232
+ releases: releases,
233
+ pattern: format_pattern,
234
+ codepush_friendly: codepush_friendly
235
+ )
236
+
237
+ #UI.message commit
238
+
239
+ if commit[:release] == "major" || commit[:is_breaking_change]
240
+ next_major += 1
241
+ next_minor = 0
242
+ next_patch = 0
243
+ elsif commit[:release] == "minor"
244
+ next_minor += 1
245
+ next_patch = 0
246
+ elsif commit[:release] == "patch"
247
+ next_patch += 1
248
+ end
237
249
 
238
- unless commit[:is_codepush_friendly]
239
- last_incompatible_codepush_version = "#{next_major}.#{next_minor}.#{next_patch}"
250
+ unless commit[:is_codepush_friendly]
251
+ last_incompatible_codepush_version = "#{next_major}.#{next_minor}.#{next_patch}"
252
+ end
240
253
  end
241
254
  end
242
255
 
@@ -304,7 +317,7 @@ module Fastlane
304
317
  FastlaneCore::ConfigItem.new(
305
318
  key: :codepush_friendly,
306
319
  description: "These types are consider as codepush friendly automatically",
307
- default_value: ["chore", "test", "docs"],
320
+ default_value: ["build", "chore", "ci", "docs", "fix", "feat", "perf", "refactor", "style", "test"],
308
321
  type: Array,
309
322
  optional: true
310
323
  ),
@@ -333,6 +346,13 @@ module Fastlane
333
346
  default_value: false,
334
347
  type: Boolean,
335
348
  optional: true
349
+ ),
350
+ FastlaneCore::ConfigItem.new(
351
+ key: :start_hash,
352
+ description: "Hash to start from when calculating versions",
353
+ default_value: "HEAD",
354
+ type: String,
355
+ optional: true
336
356
  )
337
357
  ]
338
358
  end
@@ -4,7 +4,7 @@ module Fastlane
4
4
  UI = FastlaneCore::UI unless Fastlane.const_defined?("UI")
5
5
 
6
6
  module Helper
7
- class SemanticReleaseHelper
7
+ class BetterSemanticReleaseHelper
8
8
  def self.format_patterns
9
9
  return {
10
10
  "default" => /^(docs|fix|feat|chore|style|refactor|perf|test)(?:\((.*)\))?(!?)\: (.*)/,
@@ -13,7 +13,7 @@ module Fastlane
13
13
  end
14
14
 
15
15
  # class methods that you define here become available in your action
16
- # as `Helper::SemanticReleaseHelper.your_method`
16
+ # as `Helper::BetterSemanticReleaseHelper.your_method`
17
17
  #
18
18
  def self.git_log(params)
19
19
  command = "git log --pretty='#{params[:pretty]}' --reverse #{params[:start]}..HEAD"
@@ -34,7 +34,8 @@ module Fastlane
34
34
  is_valid: false,
35
35
  subject: commit_subject,
36
36
  is_merge: !(commit_subject =~ /^Merge/).nil?,
37
- type: 'no_type'
37
+ type: 'no_type',
38
+ is_codepush_friendly: true
38
39
  }
39
40
 
40
41
  unless matched.nil?
@@ -1 +1 @@
1
- module Fastlane module BetterSemanticRelease VERSION = "1.0.0" end end
1
+ module Fastlane module BetterSemanticRelease VERSION = "2.0.2" end end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-better_semantic_release
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Greco
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-06 00:00:00.000000000 Z
11
+ date: 2022-07-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry
@@ -144,11 +144,11 @@ extra_rdoc_files: []
144
144
  files:
145
145
  - LICENSE
146
146
  - README.md
147
+ - lib/fastlane/plugin/better_semantic_release.rb
147
148
  - lib/fastlane/plugin/better_semantic_release/actions/analyze_commits.rb
148
149
  - lib/fastlane/plugin/better_semantic_release/actions/conventional_changelog.rb
149
- - lib/fastlane/plugin/better_semantic_release/helper/semantic_release_helper.rb
150
+ - lib/fastlane/plugin/better_semantic_release/helper/better_semantic_release_helper.rb
150
151
  - lib/fastlane/plugin/better_semantic_release/version.rb
151
- - lib/fastlane/plugin/semantic_release.rb
152
152
  homepage: https://github.com/tomgreco/fastlane-plugin-better_semantic_release
153
153
  licenses:
154
154
  - MIT