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

Function ensureWorktreePathSafe

pkg/cmd/pr/shared/worktree.go:116–129  ·  view source on GitHub ↗
(path string)

Source from the content-addressed store, hash-verified

114}
115
116func ensureWorktreePathSafe(path string) error {
117 fi, err := os.Lstat(path)
118 switch {
119 case os.IsNotExist(err):
120 return nil
121 case err != nil:
122 return err
123 case fi.Mode()&os.ModeSymlink != 0:
124 return fmt.Errorf("--worktree path must not be a symlink: %s", path)
125 case !fi.IsDir():
126 return fmt.Errorf("--worktree path must be a directory: %s", path)
127 }
128 return nil
129}
130
131func ensureWorktreePathEmpty(path string) error {
132 dir, err := os.Open(path)

Callers 1

ResolveWorktreeTargetFunction · 0.85

Calls 1

ErrorfMethod · 0.65

Tested by

no test coverage detected