1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Prevent permission denied when cloning

Without read permission to the current working directory, git-clone will
fail:
root@host:~$ sudo -u git -H git clone \
  git://github.com/ansible/ansible.git /home/git/ansible
fatal: Could not change back to '/root': Permission denied

This commit ensures that the working directory is changed to the
parent-folder of the destination before doing the clone.
This commit is contained in:
Gert Goet 2013-01-13 13:07:22 +01:00
parent b0ab81b237
commit f4dcb33ccc

View file

@ -80,10 +80,12 @@ def get_version(dest):
def clone(repo, dest, remote):
''' makes a new git repo if it does not already exist '''
dest_dirname = os.path.dirname(dest)
try:
os.makedirs(os.path.dirname(dest))
os.makedirs(dest_dirname)
except:
pass
os.chdir(dest_dirname)
return _run("git clone -o %s %s %s" % (remote, repo, dest))
def has_local_mods(dest):