match/lib/match/storage/git_storage.rb in fastlane-2.153.1 vs match/lib/match/storage/git_storage.rb in fastlane-2.154.0
- old
+ new
@@ -17,10 +17,11 @@
attr_accessor :clone_branch_directly
attr_accessor :type
attr_accessor :platform
attr_accessor :git_basic_authorization
attr_accessor :git_bearer_authorization
+ attr_accessor :git_private_key
def self.configure(params)
return self.new(
type: params[:type].to_s,
platform: params[:platform].to_s,
@@ -30,11 +31,12 @@
branch: params[:git_branch],
git_full_name: params[:git_full_name],
git_user_email: params[:git_user_email],
clone_branch_directly: params[:clone_branch_directly],
git_basic_authorization: params[:git_basic_authorization],
- git_bearer_authorization: params[:git_bearer_authorization]
+ git_bearer_authorization: params[:git_bearer_authorization],
+ git_private_key: params[:git_private_key]
)
end
def initialize(type: nil,
platform: nil,
@@ -44,20 +46,22 @@
branch: "master",
git_full_name: nil,
git_user_email: nil,
clone_branch_directly: false,
git_basic_authorization: nil,
- git_bearer_authorization: nil)
+ git_bearer_authorization: nil,
+ git_private_key: nil)
self.git_url = git_url
self.shallow_clone = shallow_clone
self.skip_docs = skip_docs
self.branch = branch
self.git_full_name = git_full_name
self.git_user_email = git_user_email
self.clone_branch_directly = clone_branch_directly
self.git_basic_authorization = git_basic_authorization
self.git_bearer_authorization = git_bearer_authorization
+ self.git_private_key = git_private_key
self.type = type if type
self.platform = platform if platform
end
@@ -81,9 +85,19 @@
if self.shallow_clone
command << " --depth 1 --no-single-branch"
elsif self.clone_branch_directly
command += " -b #{self.branch.shellescape} --single-branch"
+ end
+
+ unless self.git_private_key.nil?
+ if File.file?(self.git_private_key)
+ ssh_add = File.expand_path(self.git_private_key).shellescape.to_s
+ else
+ UI.message("Private key file does not exist, will continue by using it as a raw key.")
+ ssh_add = "- <<< \"#{self.git_private_key}\""
+ end
+ command = "ssh-agent bash -c 'ssh-add #{ssh_add}; #{command}'"
end
UI.message("Cloning remote git repo...")
if self.branch && !self.clone_branch_directly
UI.message("If cloning the repo takes too long, you can use the `clone_branch_directly` option in match.")