MCPcopy
hub / github.com/cli/cli / creditsRun

Function creditsRun

pkg/cmd/repo/credits/credits.go:114–246  ·  view source on GitHub ↗
(opts *CreditsOptions)

Source from the content-addressed store, hash-verified

112}
113
114func 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))

Callers 2

NewCmdCreditsFunction · 0.85
NewCmdRepoCreditsFunction · 0.85

Calls 14

RepoOwnerMethod · 0.95
RepoNameMethod · 0.95
RepoHostMethod · 0.95
NewClientFromHTTPFunction · 0.92
FromFullNameFunction · 0.92
getColorFunction · 0.85
starLineFunction · 0.85
twinkleFunction · 0.85
IsStdoutTTYMethod · 0.80
ColorSchemeMethod · 0.80
ColorFromStringMethod · 0.80
clearFunction · 0.70

Tested by

no test coverage detected