func repoDirName()

in cmd/cloudshell_open/clone.go [48:62]


func repoDirName(repo string) (string, error) {
	repo = strings.TrimSuffix(repo, ".git")
	i := strings.LastIndex(repo, "/")
	if i == -1 {
		return "", fmt.Errorf("cannot infer directory name from repo %s", repo)
	}
	dir := repo[i+1:]
	if dir == "" {
		return "", fmt.Errorf("cannot parse directory name from repo %s", repo)
	}
	if strings.HasPrefix(dir, ".") {
		return "", fmt.Errorf("attempt to clone into hidden directory: %s", dir)
	}
	return dir, nil
}