9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/indocker/repositories/cloner.rb', line 9
def clone(session, repository)
raise ArgumenError.new("only git repositories should be cloned") if !repository.is_git?
already_cloned = repository_already_cloned?(
session: session,
target_path: repository.clone_path,
remote_url: repository.remote_url,
)
git_command = if already_cloned
build_force_pull_command(
target_path: repository.clone_path,
branch_name: repository.branch,
)
else
build_clone_command(
target_path: repository.clone_path,
branch_name: repository.branch,
remote_url: repository.remote_url,
)
end
session.exec!("ssh-agent bash -c 'ssh-add ~/.ssh/#{repository.ssh_key}; #{git_command}'")
end
|