MCPcopy Index your code
hub / github.com/cli/cli / commitsRun

Function commitsRun

pkg/cmd/search/commits/commits.go:128–156  ·  view source on GitHub ↗
(opts *CommitsOptions)

Source from the content-addressed store, hash-verified

126}
127
128func commitsRun(opts *CommitsOptions) error {
129 io := opts.IO
130 if opts.WebMode {
131 url := opts.Searcher.URL(opts.Query)
132 if io.IsStdoutTTY() {
133 fmt.Fprintf(io.ErrOut, "Opening %s in your browser.\n", text.DisplayURL(url))
134 }
135 return opts.Browser.Browse(url)
136 }
137 io.StartProgressIndicator()
138 result, err := opts.Searcher.Commits(opts.Query)
139 io.StopProgressIndicator()
140 if err != nil {
141 return err
142 }
143 if len(result.Items) == 0 && opts.Exporter == nil {
144 return cmdutil.NewNoResultsError("no commits matched your search")
145 }
146 if err := io.StartPager(); err == nil {
147 defer io.StopPager()
148 } else {
149 fmt.Fprintf(io.ErrOut, "failed to start pager: %v\n", err)
150 }
151 if opts.Exporter != nil {
152 return opts.Exporter.Write(io, result.Items)
153 }
154
155 return displayResults(io, opts.Now, result)
156}
157
158func displayResults(io *iostreams.IOStreams, now time.Time, results search.CommitsResult) error {
159 if now.IsZero() {

Callers 2

TestCommitsRunFunction · 0.85
NewCmdCommitsFunction · 0.85

Calls 12

DisplayURLFunction · 0.92
NewNoResultsErrorFunction · 0.92
IsStdoutTTYMethod · 0.80
StartPagerMethod · 0.80
StopPagerMethod · 0.80
displayResultsFunction · 0.70
URLMethod · 0.65
BrowseMethod · 0.65
CommitsMethod · 0.65
StopProgressIndicatorMethod · 0.65
WriteMethod · 0.65

Tested by 1

TestCommitsRunFunction · 0.68