Commit dfc62f9d authored by Alain Takoudjou's avatar Alain Takoudjou

gitclone: allow to create symlink in repository after clone or pull

parent 5e95d882
...@@ -140,6 +140,10 @@ class Recipe(object): ...@@ -140,6 +140,10 @@ class Recipe(object):
setattr(self, option, None) setattr(self, option, None)
else: else:
setattr(self, option, value) setattr(self, option, value)
self.path_list = [self.location]
self.link_list = [link.strip()
for link in options.get('link-list', '').split('\n')
if link.strip()]
self.git_command = options.get('git-executable', '') self.git_command = options.get('git-executable', '')
if self.git_command == '': if self.git_command == '':
self.git_command = 'git' self.git_command = 'git'
...@@ -172,6 +176,16 @@ class Recipe(object): ...@@ -172,6 +176,16 @@ class Recipe(object):
command.append(revision) command.append(revision)
check_call(command, cwd=self.location) check_call(command, cwd=self.location)
def configureSymlink(self):
for link in self.link_list:
source, dest = link.split(' ')
source_path = os.path.join(self.location, source.strip())
link_path = os.path.join(self.location, dest.strip())
if os.path.islink(link_path):
os.unlink(link_path)
os.symlink(source_path, link_path)
self.path_list.append(link_path)
def install(self): def install(self):
""" """
Do a git clone. Do a git clone.
...@@ -188,7 +202,7 @@ class Recipe(object): ...@@ -188,7 +202,7 @@ class Recipe(object):
shutil.rmtree(self.location) shutil.rmtree(self.location)
else: else:
# If develop is set, assume that this is a valid working copy # If develop is set, assume that this is a valid working copy
return [self.location] return self.path_list
if getattr(self, 'branch_overrided', None): if getattr(self, 'branch_overrided', None):
print('Warning: "branch" parameter with value "%s" is ignored. ' print('Warning: "branch" parameter with value "%s" is ignored. '
...@@ -242,6 +256,7 @@ class Recipe(object): ...@@ -242,6 +256,7 @@ class Recipe(object):
# in main repo # in main repo
check_call([self.git_command, 'submodule', 'update', '--init', check_call([self.git_command, 'submodule', 'update', '--init',
'--recursive'], cwd=self.location) '--recursive'], cwd=self.location)
self.configureSymlink()
except CalledProcessError: except CalledProcessError:
print("Unable to download from git repository." print("Unable to download from git repository."
" Trying from network cache...") " Trying from network cache...")
...@@ -255,7 +270,7 @@ class Recipe(object): ...@@ -255,7 +270,7 @@ class Recipe(object):
raise UserError(GIT_CLONE_CACHE_ERROR_MESSAGE) raise UserError(GIT_CLONE_CACHE_ERROR_MESSAGE)
self.gitReset() self.gitReset()
return [self.location] return self.path_list
def deletePycFiles(self, path): def deletePycFiles(self, path):
"""Delete *.pyc files so that deleted/moved files can not be imported""" """Delete *.pyc files so that deleted/moved files can not be imported"""
...@@ -299,6 +314,7 @@ class Recipe(object): ...@@ -299,6 +314,7 @@ class Recipe(object):
# NOTE: This will put the submodule repo in a `Detached` state. # NOTE: This will put the submodule repo in a `Detached` state.
check_call([self.git_command, 'submodule', 'update', '--init', '-f', check_call([self.git_command, 'submodule', 'update', '--init', '-f',
'--recursive'], cwd=self.location) '--recursive'], cwd=self.location)
self.configureSymlink()
except: except:
# Buildout will remove the installed location and mark the part as not # Buildout will remove the installed location and mark the part as not
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment