def clone(self, repo, branch="master"):
location_index = repo+'#'+branch
if self.repos.get(location_index) is not None:
logger.debug("Repo %s already exists, reusing old." % location_index)
return
location = os.path.join(tempfile.gettempdir(), os.path.basename(location_index))
if os.path.exists(location):
logger.debug("Repo %s with branch %s already exists on disk, reusing and pulling." % (repo, branch))
self.pull(location)
else:
logger.debug("Cloning %s with branch %s" % (repo, branch))
result = subprocess.run(
["git", "clone", "-b", branch, repo, location],
stdout=subprocess.DEVNULL,
stderr=subprocess.DEVNULL,
)
result.check_returncode()
self.repos[location_index] = location
self.copies[location_index] = []
return location
评论列表
文章目录