MCPcopy Create free account
hub / github.com/cli/cli / viewRun

Function viewRun

pkg/cmd/issue/view/view.go:102–200  ·  view source on GitHub ↗
(opts *ViewOptions)

Source from the content-addressed store, hash-verified

100}
101
102func viewRun(opts *ViewOptions) error {
103 httpClient, err := opts.HttpClient()
104 if err != nil {
105 return err
106 }
107
108 baseRepo, err := opts.BaseRepo()
109 if err != nil {
110 return err
111 }
112
113 lookupFields := set.NewStringSet()
114 if opts.Exporter != nil {
115 lookupFields.AddValues(opts.Exporter.Fields())
116 } else if opts.WebMode {
117 lookupFields.Add("url")
118 } else {
119 lookupFields.AddValues(defaultFields)
120 if opts.Comments {
121 lookupFields.Add("comments")
122 lookupFields.Remove("lastComment")
123 }
124
125 // TODO projectsV1Deprecation
126 // Remove this section as we should no longer add projectCards
127 if opts.Detector == nil {
128 cachedClient := api.NewCachedHTTPClient(httpClient, time.Hour*24)
129 opts.Detector = fd.NewDetector(cachedClient, baseRepo.RepoHost())
130 }
131
132 lookupFields.Add("projectItems")
133 projectsV1Support := opts.Detector.ProjectsV1()
134 if projectsV1Support == gh.ProjectsV1Supported {
135 lookupFields.Add("projectCards")
136 }
137
138 // TODO IssueRelationshipsCleanup
139 issueFeatures, issueErr := opts.Detector.IssueFeatures()
140 if issueErr == nil && issueFeatures.IssueRelationshipsSupported {
141 lookupFields.AddValues([]string{"blockedBy", "blocking"})
142 }
143 }
144
145 opts.IO.DetectTerminalTheme()
146
147 opts.IO.StartProgressIndicator()
148 defer opts.IO.StopProgressIndicator()
149
150 lookupFields.Add("id")
151
152 issue, err := issueShared.FindIssueOrPR(httpClient, baseRepo, opts.IssueNumber, lookupFields.ToSlice())
153 if err != nil {
154 return err
155 }
156
157 if lookupFields.Contains("comments") {
158 err := preloadIssueComments(httpClient, baseRepo, issue)
159 if err != nil {

Calls 15

NewStringSetFunction · 0.92
NewCachedHTTPClientFunction · 0.92
DisplayURLFunction · 0.92
preloadIssueCommentsFunction · 0.85
printHumanIssuePreviewFunction · 0.85
printRawIssuePreviewFunction · 0.85
AddValuesMethod · 0.80
DetectTerminalThemeMethod · 0.80
ContainsMethod · 0.80
IsStdoutTTYMethod · 0.80
StartPagerMethod · 0.80