MCPcopy
hub / github.com/cli/cli / checksRun

Function checksRun

pkg/cmd/pr/checks/checks.go:148–255  ·  view source on GitHub ↗
(opts *ChecksOptions)

Source from the content-addressed store, hash-verified

146}
147
148func checksRun(opts *ChecksOptions) error {
149 if opts.WebMode {
150 return checksRunWebMode(opts)
151 }
152
153 findOptions := shared.FindOptions{
154 Selector: opts.SelectorArg,
155 Fields: []string{"number", "headRefName"},
156 }
157
158 var pr *api.PullRequest
159 pr, repo, findErr := opts.Finder.Find(findOptions)
160 if findErr != nil {
161 return findErr
162 }
163
164 client, clientErr := opts.HttpClient()
165 if clientErr != nil {
166 return clientErr
167 }
168
169 var checks []check
170 var counts checkCounts
171 var err error
172 var includeEvent bool
173
174 if opts.Detector == nil {
175 cachedClient := api.NewCachedHTTPClient(client, time.Hour*24)
176 opts.Detector = fd.NewDetector(cachedClient, repo.RepoHost())
177 }
178 if features, featuresErr := opts.Detector.PullRequestFeatures(); featuresErr != nil {
179 return featuresErr
180 } else {
181 includeEvent = features.CheckRunEvent
182 }
183
184 checks, counts, err = populateStatusChecks(client, repo, pr, opts.Required, includeEvent)
185 if err != nil {
186 return err
187 }
188
189 if opts.Exporter != nil {
190 return opts.Exporter.Write(opts.IO, checks)
191 }
192
193 if opts.Watch {
194 opts.IO.StartAlternateScreenBuffer()
195 } else {
196 // Only start pager in non-watch mode
197 if err := opts.IO.StartPager(); err == nil {
198 defer opts.IO.StopPager()
199 } else {
200 fmt.Fprintf(opts.IO.ErrOut, "failed to start pager: %v\n", err)
201 }
202 }
203
204 // Do not return err until we can StopAlternateScreenBuffer()
205 for {

Callers 2

Test_checksRunFunction · 0.85
NewCmdChecksFunction · 0.85

Calls 15

NewCachedHTTPClientFunction · 0.92
checksRunWebModeFunction · 0.85
populateStatusChecksFunction · 0.85
printSummaryFunction · 0.85
StartPagerMethod · 0.80
StopPagerMethod · 0.80
RefreshScreenMethod · 0.80
ColorSchemeMethod · 0.80
BoldfMethod · 0.80
printTableFunction · 0.70

Tested by 1

Test_checksRunFunction · 0.68