fastlane-plugin-waldo 1.2.2 → 1.3.0

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
  SHA1:
3
- metadata.gz: 056a17e44467bd00b33113d8cf52829a6b849c29
4
- data.tar.gz: 38c5bdbe260672b4ad39c59fdcbc3498118350e5
3
+ metadata.gz: 1ed8c04c2045ecc72f5bae2886d924aa267dbf01
4
+ data.tar.gz: 56f47c14e035e955ca002a891648d4a96cfc1596
5
5
  SHA512:
6
- metadata.gz: 58a2fc1db402ef97db5a7215fb23d5ee61ad017cbfb4d963e8c661ded128e4894da651ba783911f3fd5d0459a68a72f7ec5756d3a009111d460439d450aa3f08
7
- data.tar.gz: bdb76754572891b23d5ad91a5627e1245ad9a0acae7eb157903c61e5873a1f9fbc70d01fae55c51dc538b5d55d9c2a3097df9e688c2bbedba2d3f20da1289fe8
6
+ metadata.gz: 9507565edfe335c48757bc2283057b7a5235e0cf712c94fd5e70d4fd26ad3ba3f9ee8c13fcbad1126cc8c29ca178e6a188ce27d5ea85ce0fe569fba7cc6efb07
7
+ data.tar.gz: 5a07ca19ae171dddb902bfb96677c40fa0b00ab5a42b201529d89c3708d6328689105db90a081e033daf0b1fe19ddbd466a78409169cbd54eb377a66459a4f9c
@@ -1,8 +1,26 @@
1
+ require 'base64'
1
2
  require 'net/http'
2
3
 
3
4
  module Fastlane
4
5
  module Helper
5
6
  class WaldoHelper
7
+ def self.convert_commit(sha)
8
+ puts "Entering convert_commit(#{sha})"
9
+
10
+ prefix = 'remotes/origin/'
11
+ pfxlen = prefix.length
12
+
13
+ full_name = get_git_commit_name(sha)
14
+
15
+ if full_name.start_with?(prefix)
16
+ abbr_name = full_name[pfxlen..-1]
17
+ else
18
+ abbr_name = "local:#{full_name}"
19
+ end
20
+
21
+ %("#{sha[0..7]}-#{abbr_name}")
22
+ end
23
+
6
24
  def self.dump_request(request)
7
25
  len = request.body ? request.body.length : 0
8
26
 
@@ -76,6 +94,38 @@ module Fastlane
76
94
  end
77
95
  end
78
96
 
97
+ def self.get_git_commit_name(sha)
98
+ cmd = %(git name-rev --exclude='tags/*' --name-only "#{sha}")
99
+
100
+ puts "Calling: #{cmd}" if FastlaneCore::Globals.verbose?
101
+
102
+ result = Actions.sh(cmd, log: false).chomp
103
+
104
+ puts "#{cmd} => #{result}" if FastlaneCore::Globals.verbose?
105
+
106
+ result
107
+ end
108
+
109
+ def self.get_git_commits
110
+ cmd = %(git log --format=%H -50)
111
+
112
+ result = Actions.sh(cmd, log: false).chomp
113
+
114
+ puts "#{cmd} => #{result}" if FastlaneCore::Globals.verbose?
115
+
116
+ result.split(' ')
117
+ end
118
+
119
+ def self.get_history
120
+ history = get_git_commits
121
+
122
+ return '' unless !history.empty?
123
+
124
+ history = history.map { |sha| convert_commit(sha) }
125
+
126
+ Base64.strict_encode64("[#{history.join(',')}]")
127
+ end
128
+
79
129
  def self.get_platform
80
130
  Actions.lane_context[Actions::SharedValues::PLATFORM_NAME] || :ios
81
131
  end
@@ -92,6 +142,31 @@ module Fastlane
92
142
  upload_error(message) if @upload_token
93
143
  end
94
144
 
145
+ def self.has_git_command?
146
+ cmd = %(which git)
147
+
148
+ result = Actions.sh(cmd, log: false).chomp
149
+
150
+ puts "#{cmd} => #{result}" if FastlaneCore::Globals.verbose?
151
+
152
+ !result.empty?
153
+ end
154
+
155
+ def self.is_git_repository?
156
+ cmd = %(git rev-parse)
157
+
158
+ result = true
159
+
160
+ Actions.sh(cmd,
161
+ log: false,
162
+ error_callback: ->(ignore) { result = false }
163
+ ).chomp
164
+
165
+ puts "#{cmd} => #{result}" if FastlaneCore::Globals.verbose?
166
+
167
+ result
168
+ end
169
+
95
170
  def self.make_build_request(uri)
96
171
  if @apk_path
97
172
  body_path = @apk_path
@@ -128,9 +203,27 @@ module Fastlane
128
203
  end
129
204
 
130
205
  def self.make_build_uri
206
+ if !has_git_command?
207
+ history_error = "noGitCommandFound"
208
+ elsif !is_git_repository?
209
+ history_error = "notGitRepository"
210
+ else
211
+ history = get_history
212
+ end
213
+
214
+ query = ''
215
+
216
+ if history
217
+ query += "&history=#{history}"
218
+ elsif history_error
219
+ query += "&historyError=#{history_error}"
220
+ end
221
+
222
+ query += "&variantName=#{@variant_name}" if @variant_name
223
+
131
224
  uri_string = 'https://api.waldo.io/versions'
132
225
 
133
- uri_string += "?variantName=#{@variant_name}" if @variant_name
226
+ uri_string += "?#{query[1..-1]}" if !query.empty?
134
227
 
135
228
  URI(uri_string)
136
229
  end
@@ -316,7 +409,13 @@ module Fastlane
316
409
  end
317
410
 
318
411
  FileUtils.cd(cd_path) do
319
- unless Actions.sh(%(zip -qry "#{zip_path}" "#{src_path}")).empty?
412
+ cmd = %(zip -qry "#{zip_path}" "#{src_path}")
413
+
414
+ result = Actions.sh(cmd, log: false)
415
+
416
+ puts "#{cmd} => #{result}" if FastlaneCore::Globals.verbose?
417
+
418
+ unless result.empty?
320
419
  handle_error("Unable to zip app at path '#{src_path.to_s}' into '#{zip_path.to_s}'")
321
420
 
322
421
  return false
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Waldo
3
- VERSION = "1.2.2"
3
+ VERSION = "1.3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-waldo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - J. G. Pusey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-26 00:00:00.000000000 Z
11
+ date: 2019-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler