fastlane 2.63.0.beta.20171026010003 → 2.63.0.beta.20171027010003

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: fe369b68f6388108db0474221521216edfe1c2f8
4
- data.tar.gz: cd2bb45122a1099e3774699317d4548ecdbff7e7
3
+ metadata.gz: 27411efe0af1b5da1306fc3963686d2023eaeece
4
+ data.tar.gz: ea01bfb262f7c2e68a3b1a7af162778f281f8af2
5
5
  SHA512:
6
- metadata.gz: df505be58afcfc2ce336b1d53e41ed56157482ce4a5e967a7f338c382d6075b6c32ad0baeec3a984e3f9767d9b22b4e6c6059c12fdee172e479702ad170a2689
7
- data.tar.gz: f64891f727d11e8b6cc21b8b16c671a87a8800bd8032319084b233c7985470c940798d666fb465a21da85d627bea8c46f1d9ca324e1c8a1bfcca5642b109dd06
6
+ metadata.gz: fa818bfe9143d441509f2a1e9c216628456cdf3e3d529a737a4d42f6e8a2396310c14f90783a20fe8a6ccad93903e9c4e4d8644287bf42ccf19884f66d5e06cf
7
+ data.tar.gz: 3e7405094e04325f52d205f72fff02c80e3d2bef0bee231486571bea645e0aabcc6e5794da6af1eb3880975af4586b3eab5aa7240a0f4afe621099a8acbdbea0
@@ -32,6 +32,10 @@ module Fastlane
32
32
  FastlaneCore::ConfigItem.new(key: :path,
33
33
  description: "The path of the Fastfile in the repository",
34
34
  default_value: 'fastlane/Fastfile',
35
+ optional: true),
36
+ FastlaneCore::ConfigItem.new(key: :version,
37
+ description: "The version to checkout on the respository. Optimistic operator can be used to select the latest version within constraints",
38
+ default_value: nil,
35
39
  optional: true)
36
40
  ]
37
41
  end
@@ -50,6 +54,7 @@ module Fastlane
50
54
  url: "git@github.com:fastlane/fastlane.git", # The URL of the repository to import the Fastfile from.
51
55
  branch: "HEAD", # The branch to checkout on the repository. Defaults to `HEAD`.
52
56
  path: "fastlane/Fastfile" # The path of the Fastfile in the repository. Defaults to `fastlane/Fastfile`.
57
+ version: "~> 1.0.0" #The version to checkout on the respository. Optimistic operator can be used to select the latest version within constraints.
53
58
  )'
54
59
  ]
55
60
  end
@@ -225,7 +225,8 @@ module Fastlane
225
225
  # @param url [String] The git URL to clone the repository from
226
226
  # @param branch [String] The branch to checkout in the repository
227
227
  # @param path [String] The path to the Fastfile
228
- def import_from_git(url: nil, branch: 'HEAD', path: 'fastlane/Fastfile')
228
+ # @param verion [String] Version of the required Fastlane version
229
+ def import_from_git(url: nil, branch: 'HEAD', path: 'fastlane/Fastfile', version: nil)
229
230
  UI.user_error!("Please pass a path to the `import_from_git` action") if url.to_s.length == 0
230
231
 
231
232
  Actions.execute_action('import_from_git') do
@@ -235,26 +236,34 @@ module Fastlane
235
236
 
236
237
  # Checkout the repo
237
238
  repo_name = url.split("/").last
239
+ checkout_param = branch
238
240
 
239
241
  Dir.mktmpdir("fl_clone") do |tmp_path|
240
242
  clone_folder = File.join(tmp_path, repo_name)
241
243
 
242
- branch_option = ""
243
244
  branch_option = "--branch #{branch}" if branch != 'HEAD'
244
245
 
245
- clone_command = "GIT_TERMINAL_PROMPT=0 git clone '#{url}' '#{clone_folder}' --depth 1 -n #{branch_option}"
246
-
247
246
  UI.message "Cloning remote git repo..."
248
- Actions.sh(clone_command)
247
+ Actions.sh("GIT_TERMINAL_PROMPT=0 git clone '#{url}' '#{clone_folder}' --depth 1 -n #{branch_option}")
248
+
249
+ unless version.nil?
250
+ git_tags = fetch_remote_tags(folder: clone_folder)
251
+
252
+ # Separate version from optimistic operator
253
+ version_number = version(version_string: version)
254
+ operator = operator(version_string: version)
255
+
256
+ checkout_param = checkout_param_for_operator(operator: operator, version: version_number, git_tags: git_tags)
257
+ end
249
258
 
250
- Actions.sh("cd '#{clone_folder}' && git checkout #{branch} '#{path}'")
259
+ Actions.sh("cd '#{clone_folder}' && git checkout #{checkout_param} '#{path}'")
251
260
 
252
261
  # We also want to check out all the local actions of this fastlane setup
253
262
  containing = path.split(File::SEPARATOR)[0..-2]
254
263
  containing = "." if containing.count == 0
255
264
  actions_folder = File.join(containing, "actions")
256
265
  begin
257
- Actions.sh("cd '#{clone_folder}' && git checkout #{branch} '#{actions_folder}'")
266
+ Actions.sh("cd '#{clone_folder}' && git checkout #{checkout_param} '#{actions_folder}'")
258
267
  rescue
259
268
  # We don't care about a failure here, as local actions are optional
260
269
  end
@@ -268,6 +277,89 @@ module Fastlane
268
277
  end
269
278
  end
270
279
 
280
+ #####################################################
281
+ # @!group Versioning helpers
282
+ #####################################################
283
+
284
+ def fetch_remote_tags(folder: nil)
285
+ UI.message "Fetching remote git tags..."
286
+ Actions.sh("cd '#{folder}' && GIT_TERMINAL_PROMPT=0 git fetch --all --tags -q")
287
+
288
+ # Fetch all possible tags
289
+ git_tags_string = Actions.sh("cd '#{folder}' && git tag -l")
290
+ git_tags = git_tags_string.split("\n")
291
+
292
+ # Delete tags that are not a real version number
293
+ git_tags.delete_if { |tag| Gem::Version.correct?(tag) != 0 }
294
+
295
+ # Sort tags based on their version number
296
+ git_tags.sort_by { |tag| Gem::Version.new(tag) }
297
+
298
+ return git_tags
299
+ end
300
+
301
+ def checkout_param_for_operator(operator: nil, version: nil, git_tags: nil)
302
+ # ~> should select the latest version withing constraints.
303
+ # -> should select a specific version without fallback.
304
+ if operator == "~>"
305
+ return checkout_param_twiddle_wakka(version: version, git_tags: git_tags)
306
+
307
+ elsif operator == "->" || operator.nil?
308
+ return checkout_param_specific_version(version: version, git_tags: git_tags)
309
+
310
+ else
311
+ UI.user_error!("The specified operator \"#{operator}\" in \"#{version}\" is unknown. Please use one of these '~> ->'")
312
+ end
313
+ end
314
+
315
+ def checkout_param_specific_version(version: nil, git_tags: nil)
316
+ # Search matching version in array
317
+ matching_git_tags = git_tags.select do |tag|
318
+ tag == version
319
+ end
320
+
321
+ UI.user_error!("The specified version \"#{version}\" doesn't exist") if matching_git_tags.count == 0
322
+ return matching_git_tags.last
323
+ end
324
+
325
+ def checkout_param_twiddle_wakka(version: nil, git_tags: nil)
326
+ # Drop last specified digit in version
327
+ last_dot_index = version.rindex('.')
328
+ version_range = version[0..last_dot_index - 1]
329
+
330
+ # Search matching version in array
331
+ matching_git_tags = git_tags.select do |tag|
332
+ tag.start_with?(version_range)
333
+ end
334
+
335
+ UI.user_error!("No version found within the \"#{version_range}.*\" range") if matching_git_tags.count == 0
336
+
337
+ return matching_git_tags.last
338
+ end
339
+
340
+ def operator(version_string: nil)
341
+ version_info = version_range_info(version_string: version_string)
342
+
343
+ # version_info will have 2 elements if an optimistic operator is specified.
344
+ if version_info.count > 1
345
+
346
+ # Optimistic operator is always the first part. e.g.: ["~>", "2.0.0"]
347
+ return version_info.first
348
+ end
349
+
350
+ return nil
351
+ end
352
+
353
+ def version(version_string: nil)
354
+ version_info = version_range_info(version_string: version_string)
355
+ return version_info.last
356
+ end
357
+
358
+ def version_range_info(version_string: nil)
359
+ # Separate version from optimistic operator
360
+ return version_string.split(" ")
361
+ end
362
+
271
363
  #####################################################
272
364
  # @!group Overwriting Ruby methods
273
365
  #####################################################
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
- VERSION = '2.63.0.beta.20171026010003'.freeze
2
+ VERSION = '2.63.0.beta.20171027010003'.freeze
3
3
  DESCRIPTION = "The easiest way to automate beta deployments and releases for your iOS and Android apps".freeze
4
4
  MINIMUM_XCODE_RELEASE = "7.0".freeze
5
5
  RUBOCOP_REQUIREMENT = '0.49.1'.freeze
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.63.0.beta.20171026010003
4
+ version: 2.63.0.beta.20171027010003
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Krause
@@ -15,7 +15,7 @@ authors:
15
15
  autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
- date: 2017-10-26 00:00:00.000000000 Z
18
+ date: 2017-10-27 00:00:00.000000000 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: slack-notifier