MCPcopy
hub / github.com/cli/cli / commitsRun

Function commitsRun

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

Source from the content-addressed store, hash-verified

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