match/lib/match/storage/git_storage.rb in fastlane_hotfix-2.165.1 vs match/lib/match/storage/git_storage.rb in fastlane_hotfix-2.187.0
- old
+ new
@@ -87,19 +87,11 @@
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
+ command = command_from_private_key(command) unless self.git_private_key.nil?
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.")
end
@@ -168,10 +160,20 @@
def list_files(file_name: "", file_ext: "")
Dir[File.join(working_directory, "**", file_name, "*.#{file_ext}")]
end
+ def command_from_private_key(command)
+ 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
+ return "ssh-agent bash -c 'ssh-add #{ssh_add}; #{command}'"
+ end
+
private
# Create and checkout an specific branch in the git repo
def checkout_branch
return unless self.working_directory
@@ -229,10 +231,12 @@
end
def git_push(commands: [], commit_message: nil)
commit_message ||= generate_commit_message
commands << "git commit -m #{commit_message.shellescape}"
- commands << "git push origin #{self.branch.shellescape}"
+ git_push_command = "git push origin #{self.branch.shellescape}"
+ git_push_command = command_from_private_key(git_push_command) unless self.git_private_key.nil?
+ commands << git_push_command
UI.message("Pushing changes to remote git repo...")
Helper.with_env_values('GIT_TERMINAL_PROMPT' => '0') do
commands.each do |command|
FastlaneCore::CommandExecutor.execute(command: command,