MCPcopy Create free account
hub / github.com/cli/cli / newScratch

Function newScratch

script/ghmock/run.go:402–420  ·  view source on GitHub ↗
(ca *certAuthority)

Source from the content-addressed store, hash-verified

400}
401
402func newScratch(ca *certAuthority) (string, error) {
403 scratch, err := os.MkdirTemp("", "ghmock-run-")
404 if err != nil {
405 return "", err
406 }
407 for _, name := range []string{"home", "tmp", "config", "work", "certs", "templates"} {
408 if err := os.MkdirAll(filepath.Join(scratch, name), 0o755); err != nil {
409 os.RemoveAll(scratch)
410 return "", err
411 }
412 }
413 if ca != nil {
414 if err := os.WriteFile(filepath.Join(scratch, caFile), ca.certPEM, 0o600); err != nil {
415 os.RemoveAll(scratch)
416 return "", err
417 }
418 }
419 return scratch, nil
420}
421
422// resolveBinary turns a --gh value into an absolute path. A bare name is
423// looked up on PATH.

Callers 3

runBinaryFunction · 0.85
cmdRepoFunction · 0.85
cmdGitFunction · 0.85

Calls 3

MkdirAllMethod · 0.80
JoinMethod · 0.80
WriteFileMethod · 0.80

Tested by

no test coverage detected