Class: Fastlane::Actions::GitImportAction
- Inherits:
-
Action
- Object
- Action
- Fastlane::Actions::GitImportAction
- Defined in:
- lib/fastlane/plugin/git_import/actions/git_import_action.rb
Class Method Summary collapse
- .authors ⇒ Object
- .available_options ⇒ Object
- .description ⇒ Object
- .details ⇒ Object
- .example_code ⇒ Object
- .is_supported?(platform) ⇒ Boolean
- .return_value ⇒ Object
- .run(params) ⇒ Object
Class Method Details
.authors ⇒ Object
74 75 76 |
# File 'lib/fastlane/plugin/git_import/actions/git_import_action.rb', line 74 def self. ['👤 GitHub: @DmitryFrishbuter / Email: [email protected]'] end |
.available_options ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/fastlane/plugin/git_import/actions/git_import_action.rb', line 87 def self. [ FastlaneCore::ConfigItem.new(key: :url, description: "The URL of the repository to import the Fastfile from", default_value: nil), FastlaneCore::ConfigItem.new(key: :branch, description: "The branch or tag to check-out on the repository", default_value: 'HEAD', optional: true), FastlaneCore::ConfigItem.new(key: :version, description: "The version to checkout on the repository. Optimistic match operator or multiple conditions can be used to select the latest version within constraints", default_value: nil, is_string: false, optional: true), FastlaneCore::ConfigItem.new(key: :import, description: "Callback from Fastfile to perform import for every git dependency", default_value: nil, is_string: false, optional: false) ] end |
.description ⇒ Object
70 71 72 |
# File 'lib/fastlane/plugin/git_import/actions/git_import_action.rb', line 70 def self.description "Import all required fastlane dependencies from the git repository and keep your Fastfile simple!" end |
.details ⇒ Object
82 83 84 85 |
# File 'lib/fastlane/plugin/git_import/actions/git_import_action.rb', line 82 def self.details # Optional: "Import all required fastlane dependencies from the git repository and keep your Fastfile simple!" end |
.example_code ⇒ Object
117 118 119 120 121 122 123 124 125 |
# File 'lib/fastlane/plugin/git_import/actions/git_import_action.rb', line 117 def self.example_code [ 'git_import( url: "[email protected]:fastlane/fastlane.git", # The URL of the repository to import the Fastfile from. branch: "HEAD", # The branch to checkout on the repository. version: "~> 1.0.0" # The version to checkout on the repository. Optimistic match operator can be used to select the latest version within constraints. )' ] end |
.is_supported?(platform) ⇒ Boolean
109 110 111 112 113 114 115 |
# File 'lib/fastlane/plugin/git_import/actions/git_import_action.rb', line 109 def self.is_supported?(platform) # Adjust this if your plugin only works for a particular platform (iOS vs. Android, for example) # See: https://docs.fastlane.tools/advanced/#control-configuration-by-lane-and-by-platform # # [:ios, :mac, :android].include?(platform) true end |
.return_value ⇒ Object
78 79 80 |
# File 'lib/fastlane/plugin/git_import/actions/git_import_action.rb', line 78 def self.return_value # If your method provides a return value, you can describe here what it does end |
.run(params) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/fastlane/plugin/git_import/actions/git_import_action.rb', line 7 def self.run(params) require 'tmpdir' url = params[:url] branch = params[:branch] || 'HEAD' version = params[:version] import = params[:import] # puts "CURRENT DIRECTORY: #{Dir.pwd}" UI.user_error!("Please pass a url to the `git_import` action") if url.to_s.length == 0 UI.user_error!("Please pass a import callback to the `git_import` action") if import == nil # Checkout the repo repo_name = url.split("/").last checkout_param = branch Dir.mktmpdir("fl_clone") do |tmp_path| clone_folder = File.join(tmp_path, repo_name) branch_option = "--branch #{branch}" if branch != 'HEAD' UI.("Cloning remote git repo...") Helper.with_env_values('GIT_TERMINAL_PROMPT' => '0') do Actions.sh("git clone #{url.shellescape} #{clone_folder.shellescape} --depth 1 -n #{branch_option}") end unless version.nil? req = Gem::Requirement.new(version) = (folder: clone_folder) checkout_param = .select { |t| req =~ FastlaneCore::TagVersion.new(t) }.last UI.user_error!("No tag found matching #{version.inspect}") if checkout_param.nil? end common_checkout = "cd #{clone_folder.shellescape} && git checkout #{checkout_param.shellescape} *.rb" Actions.sh(common_checkout) containing = "." optional_folders = ['actions', 'helper'].map { |folder| File.join(containing, folder) } optional_folders.each do |optional_folder| begin Actions.sh("cd #{clone_folder.shellescape} && git checkout #{checkout_param.shellescape} #{optional_folder.shellescape}") rescue # We don't care about a failure here, as local additional files are optional end end clone_folder_paths = Dir.glob('*.rb', base: clone_folder) return_value = clone_folder_paths.map { |file_path| import.call(File.join(clone_folder, file_path)) } begin folder = "#{clone_folder}/helper/" file_paths = Dir.glob('*.rb', base: folder) return_value += file_paths.map { |file_path| import.call(File.join(folder, file_path))} rescue # We don't care about a failure here, as helper files are optional end return return_value end end |