mathlibtools/lib.py
def from_git_url(cls, url: str, target: str = '',
                     branch: str = '', create_branch: bool = False,
                     cache_url: str = '',
                     force_download: bool = False) -> 'LeanProject':
        """Download a Lean project using git and prepare mathlib if needed."""
        log.info('Cloning from ' + url)
        target = target or url.split('/')[-1].split('.')[0]
        repo = Repo.clone_from(url, target)
        if create_branch and branch:
            try:
                repo.git.checkout('HEAD', '-b', branch)
            except (IndexError, GitCommandError):
                log.error('Cannot create new git branch')
                shutil.rmtree(target)
                raise
        elif branch:
            try:
                repo.remote('origin').fetch(branch)
                repo.git.checkout(branch)
            except (IndexError, GitCommandError) as err:
                log.error('Invalid git branch')
                shutil.rmtree(target)
                raise err
        assert repo.working_dir is not None
        proj = cls.from_path(Path(repo.working_dir), cache_url, force_download)
        proj.run_echo(['leanpkg', 'configure'])
        if 'mathlib' in proj.deps or proj.is_mathlib:
            proj.get_mathlib_olean()
        return proj
Download a Lean project using git and prepare mathlib if needed.
Download a Lean project using git and prepare mathlib if needed.
Download a Lean project using git and prepare mathlib if needed .
def from_git_url(cls, url: str, target: str = '',
                     branch: str = '', create_branch: bool = False,
                     cache_url: str = '',
                     force_download: bool = False) -> 'LeanProject':
        log.info('Cloning from ' + url)
        target = target or url.split('/')[-1].split('.')[0]
        repo = Repo.clone_from(url, target)
        if create_branch and branch:
            try:
                repo.git.checkout('HEAD', '-b', branch)
            except (IndexError, GitCommandError):
                log.error('Cannot create new git branch')
                shutil.rmtree(target)
                raise
        elif branch:
            try:
                repo.remote('origin').fetch(branch)
                repo.git.checkout(branch)
            except (IndexError, GitCommandError) as err:
                log.error('Invalid git branch')
                shutil.rmtree(target)
                raise err
        assert repo.working_dir is not None
        proj = cls.from_path(Path(repo.working_dir), cache_url, force_download)
        proj.run_echo(['leanpkg', 'configure'])
        if 'mathlib' in proj.deps or proj.is_mathlib:
            proj.get_mathlib_olean()
        return proj
def from_git_url ( cls , url : str , target : str = '' , branch : str = '' , create_branch : bool = False , cache_url : str = '' , force_download : bool = False ) -> 'LeanProject' : log . info ( 'Cloning from ' + url ) target = target or url . split ( '/' ) [ - 1 ] . split ( '.' ) [ 0 ] repo = Repo . clone_from ( url , target ) if create_branch and branch : try : repo . git . checkout ( 'HEAD' , '-b' , branch ) except ( IndexError , GitCommandError ) : log . error ( 'Cannot create new git branch' ) shutil . rmtree ( target ) raise elif branch : try : repo . remote ( 'origin' ) . fetch ( branch ) repo . git . checkout ( branch ) except ( IndexError , GitCommandError ) as err : log . error ( 'Invalid git branch' ) shutil . rmtree ( target ) raise err assert repo . working_dir is not None proj = cls . from_path ( Path ( repo . working_dir ) , cache_url , force_download ) proj . run_echo ( [ 'leanpkg' , 'configure' ] ) if 'mathlib' in proj . deps or proj . is_mathlib : proj . get_mathlib_olean ( ) return proj
Download a Lean project using git and prepare mathlib if needed.
Download a Lean project using git and prepare mathlib if needed .
"""Download a Lean project using git and prepare mathlib if needed."""
cls
url
str
target
str
branch
str
create_branch
bool
cache_url
str
force_download
bool