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

Function hideDirectory

script/ghmock/run.go:509–520  ·  view source on GitHub ↗
(text, scratch, replacement string)

Source from the content-addressed store, hash-verified

507}
508
509func hideDirectory(text, scratch, replacement string) string {
510 paths := []string{scratch}
511 // macOS gives gh /private/var/... for a temporary folder under /var/....
512 if resolved, err := filepath.EvalSymlinks(scratch); err == nil && resolved != scratch {
513 paths = append(paths, resolved)
514 }
515 sort.Slice(paths, func(i, j int) bool { return len(paths[i]) > len(paths[j]) })
516 for _, p := range paths {
517 text = strings.ReplaceAll(text, p, replacement)
518 }
519 return text
520}
521
522// ghEnv builds gh's whole environment from scratch, so the caller's tokens,
523// config and git settings never reach it. Every run gets fresh directories,

Callers 3

runBinaryFunction · 0.85
hideScratchFunction · 0.85
cmdGitFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected