def git_clone(self, name, source):
"""
Clone the plugin from git repository.
:param name: Plugin name.
:param source: Source url.
:returns: ``True`` if successful.
:rtype: bool
"""
if git_available:
target_dir = join(self.path, "plugins", name)
temp_dir = join(self.path, "plugins", "temp_" + name)
try:
# Clone repository to temporary folder
repo = Repo.clone_from(source, temp_dir)
self.print("cloned '{}' from '{}'".format(name, source))
except:
return False
# Check if valid uj project.
try:
UjProject(temp_dir, self)
except InvalidUjProjectError:
return False
# Delete old version of project if exiting
rm(target_dir)
# Move temp dir to target location and clean.
move(temp_dir, target_dir)
rm(temp_dir)
return True
else:
return False
评论列表
文章目录