(
repository_url: str | None, branch: str | None
)
| 185 | |
| 186 | |
| 187 | def checkout_repository( |
| 188 | repository_url: str | None, branch: str | None |
| 189 | ) -> tempfile.TemporaryDirectory | None: |
| 190 | if repository_url is None: |
| 191 | return None |
| 192 | try: |
| 193 | import git |
| 194 | except ImportError: |
| 195 | logging.error("To run the code from Git repository please have git installed") |
| 196 | exit(1) |
| 197 | temp_root_directory = tempfile.TemporaryDirectory() |
| 198 | repository_path, venv_path = get_temporary_paths(temp_root_directory) |
| 199 | repository = git.Repo.clone_from(repository_url, repository_path) |
| 200 | if branch is not None: |
| 201 | repository.git.checkout(branch) |
| 202 | venv.create(venv_path, with_pip=True) |
| 203 | return temp_root_directory |
| 204 | |
| 205 | |
| 206 | def spawn_program( |
no test coverage detected