(dir string)
| 80 | } |
| 81 | |
| 82 | func createDirAndEnsureEmpty(dir string) error { |
| 83 | entries, err := os.ReadDir(dir) |
| 84 | if errors.Is(err, os.ErrNotExist) { |
| 85 | if err = os.MkdirAll(dir, 0o755); err != nil { |
| 86 | return errors.WithStack(err) |
| 87 | } |
| 88 | } else if err != nil { |
| 89 | return errors.WithStack(err) |
| 90 | } |
| 91 | |
| 92 | if len(entries) > 0 { |
| 93 | return usererr.New("directory %q is not empty", dir) |
| 94 | } |
| 95 | |
| 96 | return nil |
| 97 | } |
| 98 | |
| 99 | func ParseRepoURL(repo string) (string, error) { |
| 100 | u, err := url.Parse(repo) |
no test coverage detected