fastlane 2.178.0 → 2.182.0

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.
Files changed (148) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +97 -84
  4. data/cert/lib/cert/commands_generator.rb +2 -1
  5. data/cert/lib/cert/options.rb +1 -0
  6. data/cert/lib/cert/runner.rb +4 -0
  7. data/deliver/lib/deliver/commands_generator.rb +2 -1
  8. data/deliver/lib/deliver/download_screenshots.rb +1 -2
  9. data/deliver/lib/deliver/languages.rb +1 -1
  10. data/deliver/lib/deliver/options.rb +3 -2
  11. data/deliver/lib/deliver/runner.rb +4 -0
  12. data/deliver/lib/deliver/setup.rb +0 -1
  13. data/deliver/lib/deliver/upload_metadata.rb +2 -1
  14. data/fastlane/lib/fastlane/actions/actions_helper.rb +2 -2
  15. data/fastlane/lib/fastlane/actions/app_store_build_number.rb +5 -0
  16. data/fastlane/lib/fastlane/actions/app_store_connect_api_key.rb +3 -3
  17. data/fastlane/lib/fastlane/actions/backup_xcarchive.rb +1 -1
  18. data/fastlane/lib/fastlane/actions/build_app.rb +4 -0
  19. data/fastlane/lib/fastlane/actions/check_app_store_metadata.rb +4 -0
  20. data/fastlane/lib/fastlane/actions/clipboard.rb +3 -6
  21. data/fastlane/lib/fastlane/actions/docs/capture_ios_screenshots.md +1 -1
  22. data/fastlane/lib/fastlane/actions/docs/frame_screenshots.md +18 -1
  23. data/fastlane/lib/fastlane/actions/docs/upload_to_play_store.md +2 -1
  24. data/fastlane/lib/fastlane/actions/ensure_env_vars.rb +2 -6
  25. data/fastlane/lib/fastlane/actions/get_provisioning_profile.rb +4 -0
  26. data/fastlane/lib/fastlane/actions/get_version_number.rb +17 -10
  27. data/fastlane/lib/fastlane/actions/git_branch.rb +4 -10
  28. data/fastlane/lib/fastlane/actions/git_commit.rb +3 -1
  29. data/fastlane/lib/fastlane/actions/git_submodule_update.rb +16 -8
  30. data/fastlane/lib/fastlane/actions/git_tag_exists.rb +4 -0
  31. data/fastlane/lib/fastlane/actions/import_from_git.rb +5 -5
  32. data/fastlane/lib/fastlane/actions/install_provisioning_profile.rb +4 -0
  33. data/fastlane/lib/fastlane/actions/jira.rb +61 -14
  34. data/fastlane/lib/fastlane/actions/latest_testflight_build_number.rb +1 -0
  35. data/fastlane/lib/fastlane/actions/match_nuke.rb +59 -0
  36. data/fastlane/lib/fastlane/actions/notarize.rb +98 -51
  37. data/fastlane/lib/fastlane/actions/slack.rb +155 -133
  38. data/fastlane/lib/fastlane/actions/sourcedocs.rb +164 -0
  39. data/fastlane/lib/fastlane/actions/spaceship_logs.rb +1 -1
  40. data/fastlane/lib/fastlane/actions/update_project_provisioning.rb +1 -2
  41. data/fastlane/lib/fastlane/actions/upload_symbols_to_crashlytics.rb +4 -2
  42. data/fastlane/lib/fastlane/cli_tools_distributor.rb +1 -1
  43. data/fastlane/lib/fastlane/commands_generator.rb +2 -1
  44. data/fastlane/lib/fastlane/fast_file.rb +10 -2
  45. data/fastlane/lib/fastlane/fastlane_require.rb +7 -1
  46. data/fastlane/lib/fastlane/helper/git_helper.rb +19 -7
  47. data/fastlane/lib/fastlane/lane_manager.rb +3 -2
  48. data/fastlane/lib/fastlane/notification/slack.rb +56 -0
  49. data/fastlane/lib/fastlane/plugins/plugin_fetcher.rb +1 -2
  50. data/fastlane/lib/fastlane/plugins/plugin_info.rb +2 -2
  51. data/fastlane/lib/fastlane/plugins/plugin_info_collector.rb +1 -2
  52. data/fastlane/lib/fastlane/plugins/plugin_manager.rb +1 -2
  53. data/fastlane/lib/fastlane/plugins/template/%gem_name%.gemspec.erb +7 -6
  54. data/fastlane/lib/fastlane/plugins/template/.rubocop.yml +30 -35
  55. data/fastlane/lib/fastlane/plugins/template/spec/spec_helper.rb.erb +1 -1
  56. data/fastlane/lib/fastlane/setup/setup.rb +23 -10
  57. data/fastlane/lib/fastlane/swift_fastlane_function.rb +39 -14
  58. data/fastlane/lib/fastlane/swift_runner_upgrader.rb +2 -0
  59. data/fastlane/lib/fastlane/version.rb +2 -2
  60. data/fastlane/swift/Deliverfile.swift +1 -1
  61. data/fastlane/swift/DeliverfileProtocol.swift +3 -3
  62. data/fastlane/swift/Fastlane.swift +6852 -3824
  63. data/fastlane/swift/FastlaneSwiftRunner/FastlaneSwiftRunner.xcodeproj/project.pbxproj +4 -0
  64. data/fastlane/swift/Gymfile.swift +1 -1
  65. data/fastlane/swift/GymfileProtocol.swift +1 -1
  66. data/fastlane/swift/LaneFileProtocol.swift +9 -3
  67. data/fastlane/swift/Matchfile.swift +1 -1
  68. data/fastlane/swift/MatchfileProtocol.swift +1 -1
  69. data/fastlane/swift/OptionalConfigValue.swift +131 -0
  70. data/fastlane/swift/Precheckfile.swift +1 -1
  71. data/fastlane/swift/PrecheckfileProtocol.swift +3 -3
  72. data/fastlane/swift/RubyCommand.swift +1 -1
  73. data/fastlane/swift/Scanfile.swift +1 -1
  74. data/fastlane/swift/ScanfileProtocol.swift +5 -1
  75. data/fastlane/swift/Screengrabfile.swift +1 -1
  76. data/fastlane/swift/ScreengrabfileProtocol.swift +1 -1
  77. data/fastlane/swift/Snapshotfile.swift +1 -1
  78. data/fastlane/swift/SnapshotfileProtocol.swift +5 -1
  79. data/fastlane/swift/SocketClient.swift +2 -1
  80. data/fastlane/swift/SocketResponse.swift +4 -2
  81. data/fastlane/swift/formatting/Brewfile.lock.json +18 -16
  82. data/fastlane/swift/upgrade_manifest.json +1 -1
  83. data/fastlane_core/lib/fastlane_core.rb +22 -21
  84. data/fastlane_core/lib/fastlane_core/build_watcher.rb +50 -9
  85. data/fastlane_core/lib/fastlane_core/clipboard.rb +20 -0
  86. data/fastlane_core/lib/fastlane_core/configuration/configuration.rb +5 -3
  87. data/fastlane_core/lib/fastlane_core/helper.rb +28 -5
  88. data/fastlane_core/lib/fastlane_core/languages.rb +2 -2
  89. data/fastlane_core/lib/fastlane_core/queue_worker.rb +2 -2
  90. data/fastlane_core/lib/fastlane_core/swag.rb +1 -1
  91. data/fastlane_core/lib/fastlane_core/ui/help.erb +35 -0
  92. data/fastlane_core/lib/fastlane_core/ui/help_formatter.rb +16 -0
  93. data/fastlane_core/lib/fastlane_core/ui/implementations/shell.rb +12 -1
  94. data/frameit/lib/frameit/commands_generator.rb +2 -1
  95. data/gym/lib/gym/commands_generator.rb +2 -1
  96. data/gym/lib/gym/generators/package_command_generator.rb +4 -0
  97. data/gym/lib/gym/generators/package_command_generator_xcode7.rb +13 -8
  98. data/gym/lib/gym/runner.rb +15 -4
  99. data/match/lib/match/change_password.rb +3 -3
  100. data/match/lib/match/commands_generator.rb +2 -1
  101. data/match/lib/match/encryption/interface.rb +1 -1
  102. data/match/lib/match/encryption/openssl.rb +2 -2
  103. data/match/lib/match/module.rb +1 -0
  104. data/pem/lib/pem/commands_generator.rb +2 -1
  105. data/pilot/lib/pilot/commands_generator.rb +2 -1
  106. data/pilot/lib/pilot/manager.rb +4 -0
  107. data/pilot/lib/pilot/options.rb +3 -2
  108. data/pilot/lib/pilot/tester_exporter.rb +0 -1
  109. data/pilot/lib/pilot/tester_manager.rb +0 -1
  110. data/precheck/lib/precheck/commands_generator.rb +2 -1
  111. data/precheck/lib/precheck/options.rb +1 -0
  112. data/precheck/lib/precheck/runner.rb +4 -0
  113. data/produce/lib/produce/commands_generator.rb +2 -1
  114. data/scan/lib/scan/commands_generator.rb +2 -1
  115. data/scan/lib/scan/options.rb +10 -5
  116. data/scan/lib/scan/runner.rb +54 -1
  117. data/scan/lib/scan/test_command_generator.rb +10 -8
  118. data/screengrab/lib/screengrab/android_environment.rb +6 -4
  119. data/screengrab/lib/screengrab/commands_generator.rb +2 -1
  120. data/screengrab/lib/screengrab/runner.rb +1 -1
  121. data/sigh/lib/sigh/commands_generator.rb +2 -1
  122. data/sigh/lib/sigh/options.rb +1 -0
  123. data/sigh/lib/sigh/runner.rb +4 -0
  124. data/snapshot/lib/assets/SnapfileTemplate +1 -1
  125. data/snapshot/lib/assets/SnapshotHelper.swift +1 -1
  126. data/snapshot/lib/snapshot/commands_generator.rb +3 -1
  127. data/snapshot/lib/snapshot/options.rb +5 -0
  128. data/snapshot/lib/snapshot/reports_generator.rb +4 -0
  129. data/snapshot/lib/snapshot/simulator_launchers/launcher_configuration.rb +2 -0
  130. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher.rb +1 -1
  131. data/snapshot/lib/snapshot/simulator_launchers/simulator_launcher_base.rb +8 -4
  132. data/spaceship/README.md +2 -12
  133. data/spaceship/lib/spaceship/base.rb +2 -2
  134. data/spaceship/lib/spaceship/commands_generator.rb +4 -2
  135. data/spaceship/lib/spaceship/connect_api/models/app_screenshot.rb +1 -1
  136. data/spaceship/lib/spaceship/connect_api/models/profile.rb +6 -0
  137. data/spaceship/lib/spaceship/connect_api/provisioning/provisioning.rb +6 -2
  138. data/spaceship/lib/spaceship/connect_api/token.rb +7 -1
  139. data/spaceship/lib/spaceship/spaceauth_runner.rb +19 -9
  140. data/spaceship/lib/spaceship/tunes/members.rb +1 -1
  141. data/spaceship/lib/spaceship/ui.rb +2 -2
  142. data/supply/lib/supply/client.rb +3 -1
  143. data/supply/lib/supply/commands_generator.rb +2 -1
  144. data/supply/lib/supply/options.rb +2 -2
  145. data/supply/lib/supply/uploader.rb +1 -0
  146. metadata +53 -64
  147. data/gym/lib/gym/.runner.rb.swp +0 -0
  148. data/pilot/lib/pilot/tester_util.rb +0 -0
@@ -0,0 +1,164 @@
1
+ module Fastlane
2
+ module Actions
3
+ class SourcedocsAction < Action
4
+ def self.run(params)
5
+ UI.user_error!("You have to install sourcedocs using `brew install sourcedocs`") if `which sourcedocs`.to_s.length == 0 && !Helper.test?
6
+
7
+ command = "sourcedocs generate"
8
+ command << " --all-modules" if params[:all_modules]
9
+ command << " --spm-module #{params[:spm_module]}" unless params[:spm_module].nil?
10
+ command << " --module-name #{params[:module_name]}" unless params[:module_name].nil?
11
+ command << " --link-beginning #{params[:link_beginning]}" unless params[:link_beginning].nil?
12
+ command << " --link-ending #{params[:link_ending]}" unless params[:link_ending].nil?
13
+ command << " --output-folder #{params[:output_folder]}" unless params[:output_folder].nil?
14
+ command << " --min-acl #{params[:min_acl]}" unless params[:min_acl].nil?
15
+ command << " --module-name-path" if params[:module_name_path]
16
+ command << " --clean" if params[:clean]
17
+ command << " --collapsible" if params[:collapsible]
18
+ command << " --table-of-contents" if params[:table_of_contents]
19
+ command << " --reproducible-docs" if params[:reproducible]
20
+ unless params[:scheme].nil?
21
+ command << " -- -scheme #{params[:scheme]}"
22
+ command << " -sdk #{params[:sdk_platform]}" unless params[:sdk_platform].nil?
23
+ end
24
+ Actions.sh(command)
25
+ end
26
+
27
+ #####################################################
28
+ # @!group Documentation
29
+ #####################################################
30
+
31
+ def self.description
32
+ "Generate docs using SourceDocs"
33
+ end
34
+
35
+ def self.available_options
36
+ [
37
+ FastlaneCore::ConfigItem.new(
38
+ key: :all_modules,
39
+ env_name: 'FL_SOURCEDOCS_OUTPUT_ALL_MODULES',
40
+ description: 'Generate documentation for all modules in a Swift package',
41
+ type: Boolean,
42
+ optional: true
43
+ ),
44
+ FastlaneCore::ConfigItem.new(
45
+ key: :spm_module,
46
+ env_name: 'FL_SOURCEDOCS_SPM_MODULE',
47
+ description: 'Generate documentation for Swift Package Manager module',
48
+ type: String,
49
+ optional: true
50
+ ),
51
+ FastlaneCore::ConfigItem.new(
52
+ key: :module_name,
53
+ env_name: 'FL_SOURCEDOCS_MODULE_NAME',
54
+ description: 'Generate documentation for a Swift module',
55
+ type: String,
56
+ optional: true
57
+ ),
58
+ FastlaneCore::ConfigItem.new(
59
+ key: :link_beginning,
60
+ env_name: 'FL_SOURCEDOCS_LINK_BEGINNING',
61
+ description: 'The text to begin links with',
62
+ type: String,
63
+ optional: true
64
+ ),
65
+ FastlaneCore::ConfigItem.new(
66
+ key: :link_ending,
67
+ env_name: 'FL_SOURCEDOCS_LINK_ENDING',
68
+ description: 'The text to end links with (default: .md)',
69
+ type: String,
70
+ optional: true
71
+ ),
72
+ FastlaneCore::ConfigItem.new(
73
+ key: :output_folder,
74
+ env_name: 'FL_SOURCEDOCS_OUTPUT_FOLDER',
75
+ description: 'Output directory to clean (default: Documentation/Reference)',
76
+ type: String,
77
+ optional: false
78
+ ),
79
+ FastlaneCore::ConfigItem.new(
80
+ key: :min_acl,
81
+ env_name: 'FL_SOURCEDOCS_MIN_ACL',
82
+ description: 'Access level to include in documentation [private, fileprivate, internal, public, open] (default: public)',
83
+ type: String,
84
+ optional: true
85
+ ),
86
+ FastlaneCore::ConfigItem.new(
87
+ key: :module_name_path,
88
+ env_name: 'FL_SOURCEDOCS_MODULE_NAME_PATH',
89
+ description: 'Include the module name as part of the output folder path',
90
+ type: Boolean,
91
+ optional: true
92
+ ),
93
+ FastlaneCore::ConfigItem.new(
94
+ key: :clean,
95
+ env_name: 'FL_SOURCEDOCS_CLEAN',
96
+ description: 'Delete output folder before generating documentation',
97
+ type: Boolean,
98
+ optional: true
99
+ ),
100
+ FastlaneCore::ConfigItem.new(
101
+ key: :collapsible,
102
+ env_name: 'FL_SOURCEDOCS_COLLAPSIBLE',
103
+ description: 'Put methods, properties and enum cases inside collapsible blocks',
104
+ type: Boolean,
105
+ optional: true
106
+ ),
107
+ FastlaneCore::ConfigItem.new(
108
+ key: :table_of_contents,
109
+ env_name: 'FL_SOURCEDOCS_TABLE_OF_CONTENT',
110
+ description: 'Generate a table of contents with properties and methods for each type',
111
+ type: Boolean,
112
+ optional: true
113
+ ),
114
+ FastlaneCore::ConfigItem.new(
115
+ key: :reproducible,
116
+ env_name: 'FL_SOURCEDOCS_REPRODUCIBLE',
117
+ description: 'Generate documentation that is reproducible: only depends on the sources',
118
+ type: Boolean,
119
+ optional: true
120
+ ),
121
+ FastlaneCore::ConfigItem.new(
122
+ key: :scheme,
123
+ env_name: 'FL_SOURCEDOCS_SCHEME',
124
+ description: 'Create documentation for specific scheme',
125
+ type: String,
126
+ optional: true
127
+ ),
128
+ FastlaneCore::ConfigItem.new(
129
+ key: :sdk_platform,
130
+ env_name: 'FL_SOURCEDOCS_SDK_PlATFORM',
131
+ description: 'Create documentation for specific sdk platform',
132
+ type: String,
133
+ optional: true
134
+ )
135
+ ]
136
+ end
137
+
138
+ def self.output
139
+ end
140
+
141
+ def self.return_value
142
+ end
143
+
144
+ def self.authors
145
+ ["Kukurijek"]
146
+ end
147
+
148
+ def self.is_supported?(platform)
149
+ [:ios, :mac].include?(platform)
150
+ end
151
+
152
+ def self.example_code
153
+ [
154
+ "sourcedocs(output_folder: 'docs')",
155
+ "sourcedocs(output_folder: 'docs', clean: true, reproducible: true, scheme: 'MyApp')"
156
+ ]
157
+ end
158
+
159
+ def self.category
160
+ :documentation
161
+ end
162
+ end
163
+ end
164
+ end
@@ -124,7 +124,7 @@ module Fastlane
124
124
  end
125
125
 
126
126
  def self.return_type
127
- :array
127
+ :array_of_strings
128
128
  end
129
129
 
130
130
  def self.author
@@ -21,9 +21,8 @@ module Fastlane
21
21
  # download certificate
22
22
  unless File.exist?(params[:certificate])
23
23
  UI.message("Downloading root certificate from (#{ROOT_CERTIFICATE_URL}) to path '#{params[:certificate]}'")
24
- require 'open-uri'
25
24
  File.open(params[:certificate], "w:ASCII-8BIT") do |file|
26
- file.write(open(ROOT_CERTIFICATE_URL, "rb").read)
25
+ file.write(FastlaneCore::Helper.open_uri(ROOT_CERTIFICATE_URL, "rb").read)
27
26
  end
28
27
  end
29
28
 
@@ -5,8 +5,10 @@ module Fastlane
5
5
  require 'tmpdir'
6
6
 
7
7
  find_binary_path(params)
8
- find_gsp_path(params)
9
- find_api_token(params)
8
+ unless params[:app_id]
9
+ find_gsp_path(params)
10
+ find_api_token(params)
11
+ end
10
12
 
11
13
  if !params[:app_id] && !params[:gsp_path] && !params[:api_token]
12
14
  UI.user_error!('Either Firebase Crashlytics App ID, path to GoogleService-Info.plist or legacy Fabric API key must be given.')
@@ -23,7 +23,7 @@ module Fastlane
23
23
  def take_off
24
24
  before_import_time = Time.now
25
25
 
26
- if !ENV["FASTLANE_DISABLE_ANIMATION"]
26
+ if ENV["FASTLANE_DISABLE_ANIMATION"].nil?
27
27
  # Usually in the fastlane code base we use
28
28
  #
29
29
  # Helper.show_loading_indicator
@@ -1,5 +1,6 @@
1
1
  require 'commander'
2
2
  require 'fastlane/new_action'
3
+ require 'fastlane_core/ui/help_formatter'
3
4
 
4
5
  HighLine.track_eof = false
5
6
 
@@ -85,7 +86,7 @@ module Fastlane
85
86
  program :help, 'Author', 'Felix Krause <fastlane@krausefx.com>'
86
87
  program :help, 'Website', 'https://fastlane.tools'
87
88
  program :help, 'GitHub', 'https://github.com/fastlane/fastlane'
88
- program :help_formatter, :compact
89
+ program :help_formatter, FastlaneCore::HelpFormatter
89
90
 
90
91
  global_option('--verbose') { FastlaneCore::Globals.verbose = true }
91
92
  global_option('--capture_output', 'Captures the output of the current run, and generates a markdown issue template') do
@@ -284,7 +284,7 @@ module Fastlane
284
284
 
285
285
  action_launched('import_from_git')
286
286
 
287
- is_eligible_for_caching = !version.nil? && !cache_path.nil?
287
+ is_eligible_for_caching = !cache_path.nil?
288
288
 
289
289
  UI.message("Eligible for caching") if is_eligible_for_caching
290
290
 
@@ -338,7 +338,15 @@ module Fastlane
338
338
  UI.user_error!("No tag found matching #{version.inspect}") if checkout_param.nil?
339
339
  end
340
340
 
341
- Actions.sh("cd #{clone_folder.shellescape} && git checkout #{checkout_param.shellescape} #{checkout_path}")
341
+ if is_eligible_for_caching && version.nil?
342
+ # Update the repo if it's eligible for caching but the version isn't specified
343
+ UI.message("Fetching remote git branches and updating git repo...")
344
+ Helper.with_env_values('GIT_TERMINAL_PROMPT' => '0') do
345
+ Actions.sh("cd #{clone_folder.shellescape} && git fetch --all --quiet && git checkout #{checkout_param.shellescape} #{checkout_path} && git reset --hard && git rebase")
346
+ end
347
+ else
348
+ Actions.sh("cd #{clone_folder.shellescape} && git checkout #{checkout_param.shellescape} #{checkout_path}")
349
+ end
342
350
 
343
351
  # Knowing that we check out all the files and directories when the
344
352
  # current call is eligible for caching, we don't need to also
@@ -59,8 +59,14 @@ module Fastlane
59
59
 
60
60
  def find_gem_name(user_supplied_name)
61
61
  fetcher = Gem::SpecFetcher.fetcher
62
- gems = fetcher.suggest_gems_from_name(user_supplied_name)
63
62
 
63
+ # RubyGems 3.2.0 changed behavior of suggest_gems_from_name to no longer return user supplied name (only similar suggestions)
64
+ # First search for exact gem with detect then use suggest_gems_from_name
65
+ if (detected_gem = fetcher.detect(:latest) { |nt| nt.name == user_supplied_name }.first)
66
+ return detected_gem[0].name
67
+ end
68
+
69
+ gems = fetcher.suggest_gems_from_name(user_supplied_name)
64
70
  return gems.first
65
71
  end
66
72
 
@@ -2,6 +2,13 @@ module Fastlane
2
2
  module Actions
3
3
  GIT_MERGE_COMMIT_FILTERING_OPTIONS = [:include_merges, :exclude_merges, :only_include_merges].freeze
4
4
 
5
+ module SharedValues
6
+ GIT_BRANCH_ENV_VARS = %w(GIT_BRANCH BRANCH_NAME TRAVIS_BRANCH BITRISE_GIT_BRANCH CI_BUILD_REF_NAME CI_COMMIT_REF_NAME WERCKER_GIT_BRANCH BUILDKITE_BRANCH APPCENTER_BRANCH CIRCLE_BRANCH).reject do |branch|
7
+ # Removing because tests break on CircleCI
8
+ Helper.test? && branch == "CIRCLE_BRANCH"
9
+ end.freeze
10
+ end
11
+
5
12
  def self.git_log_between(pretty_format, from, to, merge_commit_filtering, date_format = nil, ancestry_path)
6
13
  command = %w(git log)
7
14
  command << "--pretty=#{pretty_format}"
@@ -112,14 +119,19 @@ module Fastlane
112
119
  return nil
113
120
  end
114
121
 
115
- # Returns the current git branch - can be replaced using the environment variable `GIT_BRANCH`
122
+ # Returns the current git branch, or "HEAD" if it's not checked out to any branch
123
+ # Can be replaced using the environment variable `GIT_BRANCH`
116
124
  def self.git_branch
117
- return ENV['GIT_BRANCH'] if ENV['GIT_BRANCH'].to_s.length > 0 # set by Jenkins
118
- s = Actions.sh("git rev-parse --abbrev-ref HEAD", log: false).chomp
119
- return s.to_s.strip if s.to_s.length > 0
120
- nil
121
- rescue
122
- nil
125
+ env_name = SharedValues::GIT_BRANCH_ENV_VARS.find { |env_var| FastlaneCore::Env.truthy?(env_var) }
126
+ ENV.fetch(env_name.to_s) do
127
+ # Rescues if not a git repo or no commits in a git repo
128
+ begin
129
+ Actions.sh("git rev-parse --abbrev-ref HEAD", log: false).chomp
130
+ rescue => err
131
+ UI.verbose("Error getting git branch: #{err.message}")
132
+ nil
133
+ end
134
+ end
123
135
  end
124
136
 
125
137
  private_class_method
@@ -107,12 +107,13 @@ module Fastlane
107
107
 
108
108
  puts(table)
109
109
 
110
+ fastlane_command = Helper.bundler? ? "bundle exec fastlane" : "fastlane"
110
111
  i = UI.input("Which number would you like run?")
111
112
 
112
113
  i = i.to_i - 1
113
114
  if i >= 0 && available[i]
114
115
  selection = available[i].last.pretty_name
115
- UI.important("Running lane `#{selection}`. Next time you can do this by directly typing `fastlane #{selection}` 🚀.")
116
+ UI.important("Running lane `#{selection}`. Next time you can do this by directly typing `#{fastlane_command} #{selection}` 🚀.")
116
117
  platform = selection.split(' ')[0]
117
118
  lane_name = selection.split(' ')[1]
118
119
 
@@ -123,7 +124,7 @@ module Fastlane
123
124
 
124
125
  return platform, lane_name # yeah
125
126
  else
126
- UI.user_error!("Run `fastlane` the next time you need to build, test or release your app 🚀")
127
+ UI.user_error!("Run `#{fastlane_command}` the next time you need to build, test or release your app 🚀")
127
128
  end
128
129
  end
129
130
  end
@@ -0,0 +1,56 @@
1
+ module Fastlane
2
+ module Notification
3
+ class Slack
4
+ def initialize(webhook_url)
5
+ @webhook_url = webhook_url
6
+ @client = Faraday.new do |conn|
7
+ conn.use(Faraday::Response::RaiseError)
8
+ end
9
+ end
10
+
11
+ # Overriding channel, icon_url and username is only supported in legacy incoming webhook.
12
+ # Also note that the use of attachments has been discouraged by Slack, in favor of Block Kit.
13
+ # https://api.slack.com/legacy/custom-integrations/messaging/webhooks
14
+ def post_to_legacy_incoming_webhook(channel:, username:, attachments:, link_names:, icon_url:)
15
+ @client.post(@webhook_url) do |request|
16
+ request.headers['Content-Type'] = 'application/json'
17
+ request.body = {
18
+ channel: channel,
19
+ username: username,
20
+ icon_url: icon_url,
21
+ attachments: attachments,
22
+ link_names: link_names
23
+ }.to_json
24
+ end
25
+ end
26
+
27
+ # This class was inspired by `LinkFormatter` in `slack-notifier` gem
28
+ # https://github.com/stevenosloan/slack-notifier/blob/4bf6582663dc9e5070afe3fdc42d67c14a513354/lib/slack-notifier/util/link_formatter.rb
29
+ class LinkConverter
30
+ HTML_PATTERN = %r{<a.*?href=['"](?<link>#{URI.regexp})['"].*?>(?<label>.+?)<\/a>}
31
+ MARKDOWN_PATTERN = /\[(?<label>[^\[\]]*?)\]\((?<link>#{URI.regexp}|mailto:#{URI::MailTo::EMAIL_REGEXP})\)/
32
+
33
+ def self.convert(string)
34
+ convert_markdown_to_slack_link(convert_html_to_slack_link(string.scrub))
35
+ end
36
+
37
+ def self.convert_html_to_slack_link(string)
38
+ string.gsub(HTML_PATTERN) do |match|
39
+ slack_link(Regexp.last_match[:link], Regexp.last_match[:label])
40
+ end
41
+ end
42
+
43
+ def self.convert_markdown_to_slack_link(string)
44
+ string.gsub(MARKDOWN_PATTERN) do |match|
45
+ slack_link(Regexp.last_match[:link], Regexp.last_match[:label])
46
+ end
47
+ end
48
+
49
+ def self.slack_link(href, text)
50
+ return "<#{href}>" if text.nil? || text.empty?
51
+ "<#{href}|#{text}>"
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -7,14 +7,13 @@ module Fastlane
7
7
  # Returns an array of FastlanePlugin objects
8
8
  def self.fetch_gems(search_query: nil)
9
9
  require 'json'
10
- require 'open-uri'
11
10
 
12
11
  page = 1
13
12
  plugins = []
14
13
  loop do
15
14
  url = "https://rubygems.org/api/v1/search.json?query=#{PluginManager.plugin_prefix}&page=#{page}"
16
15
  FastlaneCore::UI.verbose("RubyGems API Request: #{url}")
17
- results = JSON.parse(open(url).read)
16
+ results = JSON.parse(FastlaneCore::Helper.open_uri(url).read)
18
17
  break if results.count == 0
19
18
 
20
19
  plugins += results.collect do |current|
@@ -33,11 +33,11 @@ module Fastlane
33
33
 
34
34
  # Used to expose a local binding for use in ERB templating
35
35
  #
36
- # rubocop:disable Style/AccessorMethodName
36
+ # rubocop:disable Naming/AccessorMethodName
37
37
  def get_binding
38
38
  binding
39
39
  end
40
- # rubocop:enable Style/AccessorMethodName
40
+ # rubocop:enable Naming/AccessorMethodName
41
41
 
42
42
  def ==(other)
43
43
  @plugin_name == other.plugin_name &&
@@ -65,10 +65,9 @@ module Fastlane
65
65
 
66
66
  # Checks if the gem name is still free on RubyGems
67
67
  def gem_name_taken?(name)
68
- require 'open-uri'
69
68
  require 'json'
70
69
  url = "https://rubygems.org/api/v1/gems/#{name}.json"
71
- response = JSON.parse(open(url).read)
70
+ response = JSON.parse(FastlaneCore::Helper.open_uri(url).read)
72
71
  return !!response['version']
73
72
  rescue
74
73
  false
@@ -155,11 +155,10 @@ module Fastlane
155
155
  #####################################################
156
156
 
157
157
  def self.fetch_gem_info_from_rubygems(gem_name)
158
- require 'open-uri'
159
158
  require 'json'
160
159
  url = "https://rubygems.org/api/v1/gems/#{gem_name}.json"
161
160
  begin
162
- JSON.parse(URI.open(url).read)
161
+ JSON.parse(FastlaneCore::Helper.open_uri(url).read)
163
162
  rescue
164
163
  nil
165
164
  end