(opts *CloneOptions)
| 109 | } |
| 110 | |
| 111 | func cloneRun(opts *CloneOptions) error { |
| 112 | httpClient, err := opts.HttpClient() |
| 113 | if err != nil { |
| 114 | return err |
| 115 | } |
| 116 | |
| 117 | cfg, err := opts.Config() |
| 118 | if err != nil { |
| 119 | return err |
| 120 | } |
| 121 | |
| 122 | apiClient := api.NewClientFromHTTP(httpClient) |
| 123 | |
| 124 | repositoryIsURL := strings.Contains(opts.Repository, ":") |
| 125 | repositoryIsFullName := !repositoryIsURL && strings.Contains(opts.Repository, "/") |
| 126 | |
| 127 | var repo ghrepo.Interface |
| 128 | var protocol string |
| 129 | |
| 130 | if repositoryIsURL { |
| 131 | initialURL, err := git.ParseURL(opts.Repository) |
| 132 | if err != nil { |
| 133 | return err |
| 134 | } |
| 135 | |
| 136 | repoURL := simplifyURL(initialURL) |
| 137 | repo, err = ghrepo.FromURL(repoURL) |
| 138 | if err != nil { |
| 139 | return err |
| 140 | } |
| 141 | if repoURL.Scheme == "git+ssh" { |
| 142 | repoURL.Scheme = "ssh" |
| 143 | } |
| 144 | protocol = repoURL.Scheme |
| 145 | } else { |
| 146 | var fullName string |
| 147 | if repositoryIsFullName { |
| 148 | fullName = opts.Repository |
| 149 | } else { |
| 150 | host, _ := cfg.Authentication().DefaultHost() |
| 151 | currentUser, err := api.CurrentLoginName(apiClient, host) |
| 152 | if err != nil { |
| 153 | return err |
| 154 | } |
| 155 | fullName = currentUser + "/" + opts.Repository |
| 156 | } |
| 157 | |
| 158 | repo, err = ghrepo.FromFullName(fullName) |
| 159 | if err != nil { |
| 160 | return err |
| 161 | } |
| 162 | |
| 163 | protocol = cfg.GitProtocol(repo.RepoHost()).Value |
| 164 | } |
| 165 | |
| 166 | wantsWiki := strings.HasSuffix(repo.RepoName(), ".wiki") |
| 167 | if wantsWiki { |
| 168 | repoName := strings.TrimSuffix(repo.RepoName(), ".wiki") |
no test coverage detected