9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/fastlane/plugin/yalantis_ci/helper/git_helper.rb', line 9
def self.clone_repo_in_tmp(repo_url, branch = 'master', create_branch_if_needed = false)
temp_directory = `mktemp -d`.tr("\n", "")
begin
Dir.chdir(temp_directory) do
Actions.sh("git clone -b #{branch} #{repo_url} #{Dir.pwd}") do |status, result, cmd|
if status.success? != true && create_branch_if_needed
Actions.sh("git clone #{repo_url} #{Dir.pwd} && git checkout -b #{branch}") do |status, result, cmd |
if status.success? != true
raise StandardError.new result
end
end
elsif status.success? != true
raise StandardError.new result
end
end
yield(Dir.pwd)
end
ensure
Actions.sh("rm -rf #{temp_directory}")
end
end
|