fastlane-plugin-semantic_release 1.0.8 → 1.0.10

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: 06f275a6ba5ed94f9ddca8382caab148ca9d3eb5258f69929e2dbf812b685076
4
- data.tar.gz: 9e1e30f5f2e34a270f972d2dc5ea41121898ff386b0d092ae3ea0a26cc3f483d
3
+ metadata.gz: ac02402f73c5effd089ddc2f1ae514240bd9edc0dd7d14b2775b2999244d4d78
4
+ data.tar.gz: 5eb38e8a63b0164842031f808cda9cbcea4983fe034a2a23ef5452c9e11a0685
5
5
  SHA512:
6
- metadata.gz: 8f75f488c4c526ff5c4e225f3ade6767fa50b9dcba9ac76bda5850f2cd3cc6c58e70fe6742921911dbb766df8bc1538df79af8f1561faed0483720490eb6ed20
7
- data.tar.gz: f73eb17cd7638e7a90283522eef7c67b8b42d7c2f68aa51a26b726519dcf1026dde3d53678301a6496c968e42bbb98b2aed2d536ec7568f2d7701a069a5b44de
6
+ metadata.gz: 9382dc98a8981951e180c62993f1f6f91c115050fb37383f8919b2dde6fbf3338bec364df8ce9433a3b69d401f816393df5ec89849baa9b5a3f48e5ece103be7
7
+ data.tar.gz: b7adae6d27238228d8fce4d769e065a9e503863481cce5ff1db780d8cc759007b150a32b3d10c79bf0d2b9b1a9fe2ec93b2d0ecb2776cf9ae332adbc8c7c8f2f
@@ -15,22 +15,63 @@ module Fastlane
15
15
  end
16
16
 
17
17
  class AnalyzeCommitsAction < Action
18
+ def self.get_last_tag(params)
19
+ # Try to find the tag
20
+ command = "git describe --tags --match=#{params[:match]}"
21
+ Actions.sh(command, log: false)
22
+ rescue
23
+ UI.message("Tag was not found for match pattern - #{params[:match]}")
24
+ end
25
+
26
+ def self.get_last_tag_hash(params)
27
+ command = "git rev-list -n 1 #{params[:tag_name]}"
28
+ Actions.sh(command, log: false).chomp
29
+ end
30
+
31
+ def self.get_commits_from_hash(params)
32
+ commits = Helper::SemanticReleaseHelper.git_log('%s', params[:hash])
33
+ commits.split("\n")
34
+ end
35
+
36
+ def self.parse_commit(params)
37
+ commit = params[:commit]
38
+ releases = params[:releases]
39
+ pattern = /(docs|fix|feat|chore|style|refactor|perf|test)(\((.*)\))?!?\: /
40
+ breaking_change_pattern = /BREAKING CHANGES?: (.*)/
41
+
42
+ matched = commit.match(pattern)
43
+ result = {
44
+ is_valid: false
45
+ }
46
+
47
+ unless matched.nil?
48
+ type = matched[1]
49
+ scope = matched[3]
50
+
51
+ result[:is_valid] = true
52
+ result[:type] = type
53
+ result[:scope] = scope
54
+ result[:release] = releases[type.to_sym]
55
+
56
+ breaking_change_matched = commit.match(breaking_change_pattern)
57
+
58
+ unless breaking_change_matched.nil?
59
+ result[:is_breaking_change] = true
60
+ result[:breaking_change] = breaking_change_matched[1]
61
+ end
62
+ end
63
+
64
+ result
65
+ end
66
+
18
67
  def self.run(params)
19
- # Last version tag name
20
- tag = ""
21
68
  # Hash of the commit where is the last version
22
69
  # If the tag is not found we are taking HEAD as reference
23
70
  hash = 'HEAD'
24
71
  # Default last version
25
72
  version = '0.0.0'
26
73
 
27
- begin
28
- # Try to find the tag
29
- command = "git describe --tags --match=#{params[:match]}"
30
- tag = Actions.sh(command, log: false)
31
- rescue
32
- UI.message("Tag was not found for match pattern - #{params[:match]}")
33
- end
74
+ tag = get_last_tag(match: params[:match])
34
75
 
35
76
  if tag.empty?
36
77
  UI.message("First commit of the branch is taken as a begining of next release")
@@ -48,8 +89,7 @@ module Fastlane
48
89
 
49
90
  version = parsed_version[0]
50
91
  # Get a hash of last version tag
51
- command = "git rev-list -n 1 #{tag_name}"
52
- hash = Actions.sh(command, log: false).chomp
92
+ hash = get_last_tag_hash(tag_name: tag_name)
53
93
 
54
94
  UI.message("Found a tag #{tag_name} associated with version #{version}")
55
95
  end
@@ -60,8 +100,7 @@ module Fastlane
60
100
  next_patch = (version.split('.')[2] || 0).to_i
61
101
 
62
102
  # Get commits log between last version and head
63
- commits = Helper::SemanticReleaseHelper.git_log('%s', hash)
64
- splitted = commits.split("\n")
103
+ splitted = get_commits_from_hash(hash: hash)
65
104
 
66
105
  UI.message("Found #{splitted.length} commits since last release")
67
106
  releases = params[:releases]
@@ -69,18 +108,17 @@ module Fastlane
69
108
  splitted.each do |line|
70
109
  # conventional commits are in format
71
110
  # type: subject (fix: app crash - for example)
72
- type = line.split(":")[0]
73
- release = releases[type.to_sym]
111
+ commit = parse_commit(commit: line, releases: releases)
74
112
 
75
- if release == "patch"
76
- next_patch += 1
77
- elsif release == "minor"
78
- next_minor += 1
79
- next_patch = 0
80
- elsif release == "major"
113
+ if commit[:release] == "major" || commit[:is_breaking_change]
81
114
  next_major += 1
82
115
  next_minor = 0
83
116
  next_patch = 0
117
+ elsif commit[:release] == "minor"
118
+ next_minor += 1
119
+ next_patch = 0
120
+ elsif commit[:release] == "patch"
121
+ next_patch += 1
84
122
  end
85
123
 
86
124
  next_version = "#{next_major}.#{next_minor}.#{next_patch}"
@@ -1 +1 @@
1
- module Fastlane module SemanticRelease VERSION = "1.0.8" end end
1
+ module Fastlane module SemanticRelease VERSION = "1.0.10" 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.0.8
4
+ version: 1.0.10
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: 2019-03-20 00:00:00.000000000 Z
11
+ date: 2019-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry