(opts *CreditsOptions)
| 112 | } |
| 113 | |
| 114 | func creditsRun(opts *CreditsOptions) error { |
| 115 | isWindows := runtime.GOOS == "windows" |
| 116 | httpClient, err := opts.HttpClient() |
| 117 | if err != nil { |
| 118 | return err |
| 119 | } |
| 120 | |
| 121 | client := api.NewClientFromHTTP(httpClient) |
| 122 | |
| 123 | var baseRepo ghrepo.Interface |
| 124 | if opts.Repository == "" { |
| 125 | baseRepo, err = opts.BaseRepo() |
| 126 | if err != nil { |
| 127 | return err |
| 128 | } |
| 129 | } else { |
| 130 | baseRepo, err = ghrepo.FromFullName(opts.Repository) |
| 131 | if err != nil { |
| 132 | return err |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | type Contributor struct { |
| 137 | Login string |
| 138 | Type string |
| 139 | } |
| 140 | |
| 141 | type Result []Contributor |
| 142 | |
| 143 | result := Result{} |
| 144 | body := bytes.NewBufferString("") |
| 145 | path := fmt.Sprintf("repos/%s/%s/contributors", baseRepo.RepoOwner(), baseRepo.RepoName()) |
| 146 | |
| 147 | err = client.REST(baseRepo.RepoHost(), "GET", path, body, &result) |
| 148 | if err != nil { |
| 149 | return err |
| 150 | } |
| 151 | |
| 152 | isTTY := opts.IO.IsStdoutTTY() |
| 153 | |
| 154 | static := opts.Static || isWindows |
| 155 | |
| 156 | out := opts.IO.Out |
| 157 | cs := opts.IO.ColorScheme() |
| 158 | |
| 159 | if isTTY && static { |
| 160 | fmt.Fprintln(out, "THANK YOU CONTRIBUTORS!!! <3") |
| 161 | fmt.Fprintln(out, "") |
| 162 | } |
| 163 | |
| 164 | logins := []string{} |
| 165 | for x, c := range result { |
| 166 | if c.Type != "User" { |
| 167 | continue |
| 168 | } |
| 169 | |
| 170 | if isTTY && !static { |
| 171 | logins = append(logins, cs.ColorFromString(getColor(x))(c.Login)) |
no test coverage detected