fastlane/lib/fastlane/fast_file.rb in fastlane-2.140.0 vs fastlane/lib/fastlane/fast_file.rb in fastlane-2.141.0
- old
+ new
@@ -261,11 +261,11 @@
# @param url [String] The git URL to clone the repository from
# @param branch [String] The branch to checkout in the repository
# @param path [String] The path to the Fastfile
# @param version [String, Array] Version requirement for repo tags
- def import_from_git(url: nil, branch: 'HEAD', path: 'fastlane/Fastfile', version: nil)
+ def import_from_git(url: nil, branch: 'HEAD', path: 'fastlane/Fastfile', version: nil, dependencies: [])
UI.user_error!("Please pass a path to the `import_from_git` action") if url.to_s.length == 0
Actions.execute_action('import_from_git') do
require 'tmpdir'
@@ -278,10 +278,14 @@
Dir.mktmpdir("fl_clone") do |tmp_path|
clone_folder = File.join(tmp_path, repo_name)
branch_option = "--branch #{branch}" if branch != 'HEAD'
+ checkout_dependencies = dependencies.map(&:shellescape).join(" ")
+
+ checkout_path = "#{path.shellescape} #{checkout_dependencies}"
+
UI.message("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
@@ -290,11 +294,11 @@
all_tags = fetch_remote_tags(folder: clone_folder)
checkout_param = all_tags.select { |t| req =~ FastlaneCore::TagVersion.new(t) }.last
UI.user_error!("No tag found matching #{version.inspect}") if checkout_param.nil?
end
- Actions.sh("cd #{clone_folder.shellescape} && git checkout #{checkout_param.shellescape} #{path.shellescape}")
+ Actions.sh("cd #{clone_folder.shellescape} && git checkout #{checkout_param.shellescape} #{checkout_path}")
# We also want to check out all the local actions of this fastlane setup
containing = path.split(File::SEPARATOR)[0..-2]
containing = "." if containing.count == 0
actions_folder = File.join(containing, "actions")
@@ -302,10 +306,16 @@
Actions.sh("cd #{clone_folder.shellescape} && git checkout #{checkout_param.shellescape} #{actions_folder.shellescape}")
rescue
# We don't care about a failure here, as local actions are optional
end
- return_value = import(File.join(clone_folder, path))
+ return_value = nil
+ if dependencies.any?
+ return_value = [import(File.join(clone_folder, path))]
+ return_value += dependencies.map { |file_path| import(File.join(clone_folder, file_path)) }
+ else
+ return_value = import(File.join(clone_folder, path))
+ end
action_completed('import_from_git', status: FastlaneCore::ActionCompletionStatus::SUCCESS)
return return_value
end