def get_project(name: str, new_branch: bool, directory: str = '') -> None: """Clone a project from a GitHub name or git url. Put it in dir if this argument is given. A GitHub name without / will be considered as a leanprover-community project. If the name ends with ':foo' then foo will be interpreted as a branch name, and that branch will be checked out. This will fail if the branch does not exist. If you want to create a new branch, pass the `-b` option.""" original_name = name name, url, branch, is_url = parse_project_name(original_name) if branch: name = name + '_' + branch directory = directory or name if directory and Path(directory).exists(): raise FileExistsError('Directory ' + directory + ' already exists') try: LeanProject.from_git_url(url, directory, branch, new_branch, cache_url, force_download) except GitCommandError as err: # if full url is provided, do not retry with HTTPS if not is_url: log.info('Error cloning via SSH, trying HTTPS...') try: name, url, branch, is_url = parse_project_name(original_name, ssh=False) LeanProject.from_git_url(url, directory, branch, new_branch, cache_url, force_download) except GitCommandError as e: handle_exception(e, e.stderr) else: handle_exception(err, err.stderr)
def check() -> None: """Check mathlib oleans are more recent than their sources""" project = proj() core_ok, mathlib_ok = project.check_timestamps() toolchain = project.toolchain toolchain_path = Path.home()/'.elan'/'toolchains'/toolchain if not core_ok: print('Some core oleans files in toolchain {} seem older than ' 'their source.'.format(toolchain)) touch = input('Do you want to set their modification time to now (y/n) ? ') if touch.lower() in ['y', 'yes']: touch_oleans(toolchain_path) if not mathlib_ok: print('Some mathlib oleans files seem older than their source.') touch = input('Do you want to set their modification time to now (y/n) ? ') if touch.lower() in ['y', 'yes']: touch_oleans(project.mathlib_folder/'src') if core_ok and mathlib_ok: log.info('Everything looks fine.')