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

Function viewRun

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

Source from the content-addressed store, hash-verified

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