git.py 文件源码

python
阅读 33 收藏 0 点赞 0 评论 0

项目:bridge-test 作者: Half-Shot 项目源码 文件源码
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
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号