MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / mkrepo

Function mkrepo

misc/python/materialize/scratch.py:339–375  ·  view source on GitHub ↗
(
    instance: Instance, rev: str, init: bool = True, force: bool = False
)

Source from the content-addressed store, hash-verified

337
338
339def 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
378class MachineDesc(BaseModel):

Callers 2

runFunction · 0.90
setupFunction · 0.85

Calls 4

msshFunction · 0.85
instance_hostFunction · 0.85
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected