| 337 | |
| 338 | |
| 339 | def mkrepo( |
| 340 | instance: Instance, rev: str, init: bool = True, force: bool = False |
| 341 | ) -> None: |
| 342 | if init: |
| 343 | mssh(instance, "git clone https://github.com/MaterializeInc/materialize.git") |
| 344 | |
| 345 | rev = git.rev_parse(rev) |
| 346 | |
| 347 | cmd: list[str] = [ |
| 348 | "git", |
| 349 | "push", |
| 350 | "--no-verify", |
| 351 | f"{instance_host(instance)}:materialize/.git", |
| 352 | # Explicit refspec is required if the host repository is in detached |
| 353 | # HEAD mode. |
| 354 | f"{rev}:refs/heads/scratch", |
| 355 | ] |
| 356 | if force: |
| 357 | cmd.append("--force") |
| 358 | |
| 359 | spawn.runv( |
| 360 | cmd, |
| 361 | cwd=MZ_ROOT, |
| 362 | env=dict(os.environ, GIT_SSH_COMMAND=" ".join(SSH_COMMAND)), |
| 363 | ) |
| 364 | git_config_cmds = f"git checkout -f {rev}" |
| 365 | |
| 366 | # Propagate local git user.name and user.email to the scratch instance. |
| 367 | if git_name := git.get_user_name(): |
| 368 | git_config_cmds += f" && git config user.name {shlex.quote(git_name)}" |
| 369 | if git_email := git.get_user_email(): |
| 370 | git_config_cmds += f" && git config user.email {shlex.quote(git_email)}" |
| 371 | |
| 372 | mssh( |
| 373 | instance, |
| 374 | f"cd materialize && {git_config_cmds}", |
| 375 | ) |
| 376 | |
| 377 | |
| 378 | class MachineDesc(BaseModel): |