fastlane-plugin-semantic_release 1.13.1 → 1.14.1

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: 51884916218331bb9965b7005bdb173d6a4ce3a03fe4f348c99d495b71b8fb45
4
- data.tar.gz: 9625cfb05fa43bd29976b9b1e345c0a2d1cfb61b49876363d57a2693a2adf4e6
3
+ metadata.gz: 75df4d8576b964aa25eb049f7327b6dca63e183e6ed2ee338a9bed8c52364c35
4
+ data.tar.gz: '08f19dc2c0343275cd8ad6df77e34c3cead327543beaab51ed6211005466977a'
5
5
  SHA512:
6
- metadata.gz: 95a8a2168616e88c3a23fb8181941b8da9af9eab428b7260a7faf3ac504f812737066fb03c36ae503e4afa6fce62d31322088afe06676f97d558993e6705d559
7
- data.tar.gz: e121b05b367d96cf315f15546957fd0dccb5c75538cd799981756a46279752d20ce6080b114f842ec9a3e09d4d9c18a5acb15a56afe04aced99b8c8921f6c15c
6
+ metadata.gz: 1fe944d2e2bb270c994d168fd5c0df781b425e7e92d53535f98fd13b72eb86d153ac76800374453769653ebc14359dcf9ca0db77858361a1b53661705f5b187d
7
+ data.tar.gz: 3eff9484e9f5d5bef71a0a8252daa782a9301401886371516a8c3bb041bd137413bf49defaccdabee5477aa18313b800cced10745a4edd790539ae5e5cee0fed
@@ -41,42 +41,76 @@ module Fastlane
41
41
  commits.split("|>")
42
42
  end
43
43
 
44
- def self.is_releasable(params)
45
- # Hash of the commit where is the last version
46
- # If the tag is not found we are taking HEAD as reference
47
- hash = 'HEAD'
48
- # Default last version
49
- version = '0.0.0'
44
+ def self.get_beginning_of_next_sprint(params)
45
+ # command to get first commit
46
+ git_command = 'git rev-list --max-parents=0 HEAD'
50
47
 
51
- tag = get_last_tag(
52
- match: params[:match],
53
- debug: params[:debug]
54
- )
48
+ tag = get_last_tag(match: params[:match], debug: params[:debug])
55
49
 
50
+ # if tag doesn't exist it get's first commit or fallback tag (v*.*.*)
56
51
  if tag.empty?
57
- UI.message("First commit of the branch is taken as a begining of next release")
52
+ UI.message("It couldn't match tag for #{params[:match]}. Check if first commit can be taken as a beginning of next release")
58
53
  # If there is no tag found we taking the first commit of current branch
59
- hash = Actions.sh('git rev-list --max-parents=0 HEAD', log: params[:debug]).chomp
60
- else
61
- # Tag's format is v2.3.4-5-g7685948
62
- # See git describe man page for more info
63
- tag_name = tag.split('-')[0...-2].join('-').strip
64
- parsed_version = tag_name.match(params[:tag_version_match])
65
-
66
- if parsed_version.nil?
67
- UI.user_error!("Error while parsing version from tag #{tag_name} by using tag_version_match - #{params[:tag_version_match]}. Please check if the tag contains version as you expect and if you are using single brackets for tag_version_match parameter.")
54
+ hash_lines = Actions.sh("#{git_command} | wc -l", log: params[:debug]).chomp
55
+
56
+ if hash_lines.to_i == 1
57
+ UI.message("First commit of the branch is taken as a begining of next release")
58
+ return {
59
+ # here we know this command will return 1 line
60
+ hash: Actions.sh(git_command, log: params[:debug]).chomp
61
+ }
68
62
  end
69
63
 
70
- version = parsed_version[0]
71
- # Get a hash of last version tag
72
- hash = get_last_tag_hash(
73
- tag_name: tag_name,
74
- debug: params[:debug]
75
- )
64
+ # neighter matched tag and first hash could be used - as fallback we try vX.Y.Z
65
+ UI.message("It couldn't match tag for #{params[:match]} and couldn't use first commit. Check if tag vX.Y.Z can be taken as a begining of next release")
66
+ tag = get_last_tag(match: "v*", debug: params[:debug])
67
+
68
+ # even fallback tag doesn't work
69
+ if tag.empty?
70
+ return false
71
+ end
72
+ end
73
+
74
+ # Tag's format is v2.3.4-5-g7685948
75
+ # See git describe man page for more info
76
+ tag_name = tag.split('-')[0...-2].join('-').strip
77
+ parsed_version = tag_name.match(params[:tag_version_match])
78
+
79
+ if parsed_version.nil?
80
+ UI.user_error!("Error while parsing version from tag #{tag_name} by using tag_version_match - #{params[:tag_version_match]}. Please check if the tag contains version as you expect and if you are using single brackets for tag_version_match parameter.")
81
+ end
76
82
 
77
- UI.message("Found a tag #{tag_name} associated with version #{version}")
83
+ version = parsed_version[0]
84
+ # Get a hash of last version tag
85
+ hash = get_last_tag_hash(
86
+ tag_name: tag_name,
87
+ debug: params[:debug]
88
+ )
89
+
90
+ UI.message("Found a tag #{tag_name} associated with version #{version}")
91
+
92
+ return {
93
+ hash: hash,
94
+ version: version
95
+ }
96
+ end
97
+
98
+ def self.is_releasable(params)
99
+ # Hash of the commit where is the last version
100
+ beginning = get_beginning_of_next_sprint(params)
101
+
102
+ unless beginning
103
+ UI.error('It could not find a begining of this sprint. How to fix this:')
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")')
105
+ 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)')
106
+ return false
78
107
  end
79
108
 
109
+ # Default last version
110
+ version = beginning[:version] || '0.0.0'
111
+ # If the tag is not found we are taking HEAD as reference
112
+ hash = beginning[:hash] || 'HEAD'
113
+
80
114
  # converts last version string to the int numbers
81
115
  next_major = (version.split('.')[0] || 0).to_i
82
116
  next_minor = (version.split('.')[1] || 0).to_i
@@ -35,7 +35,7 @@ module Fastlane
35
35
  hash: last_tag_hash,
36
36
  debug: params[:debug]
37
37
  )
38
- parsed = parse_commits(commits)
38
+ parsed = parse_commits(commits, params)
39
39
 
40
40
  commit_url = params[:commit_url]
41
41
  format = params[:format]
@@ -172,7 +172,7 @@ module Fastlane
172
172
  end
173
173
  end
174
174
 
175
- def self.parse_commits(commits)
175
+ def self.parse_commits(commits, params)
176
176
  parsed = []
177
177
  # %s|%b|%H|%h|%an|%at
178
178
  format_pattern = lane_context[SharedValues::CONVENTIONAL_CHANGELOG_ACTION_FORMAT_PATTERN]
@@ -185,6 +185,14 @@ module Fastlane
185
185
  pattern: format_pattern
186
186
  )
187
187
 
188
+ unless commit[:scope].nil?
189
+ # 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
190
+ scope = commit[:scope]
191
+ scopes_to_ignore = params[:ignore_scopes]
192
+ # if it is, we'll skip this commit when bumping versions
193
+ next if scopes_to_ignore.include?(scope) #=> true
194
+ end
195
+
188
196
  commit[:hash] = splitted[2]
189
197
  commit[:short_hash] = splitted[3]
190
198
  commit[:author_name] = splitted[4]
@@ -273,6 +281,13 @@ module Fastlane
273
281
  type: Boolean,
274
282
  optional: true
275
283
  ),
284
+ FastlaneCore::ConfigItem.new(
285
+ key: :ignore_scopes,
286
+ description: "To ignore certain scopes when calculating releases",
287
+ default_value: [],
288
+ type: Array,
289
+ optional: true
290
+ ),
276
291
  FastlaneCore::ConfigItem.new(
277
292
  key: :debug,
278
293
  description: "True if you want to log out a debug info",
@@ -1 +1 @@
1
- module Fastlane module SemanticRelease VERSION = "1.13.1" end end
1
+ module Fastlane module SemanticRelease VERSION = "1.14.1" 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.13.1
4
+ version: 1.14.1
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: 2021-02-14 00:00:00.000000000 Z
11
+ date: 2021-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry