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

Function viewRun

pkg/cmd/issue/view/view.go:105–202  ·  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 opts.Detector = fd.NewCachedDetector(httpClient, baseRepo.RepoHost(), time.Hour*24)
132 }
133
134 lookupFields.Add("projectItems")
135 projectsV1Support := opts.Detector.ProjectsV1()
136 if projectsV1Support == gh.ProjectsV1Supported {
137 lookupFields.Add("projectCards")
138 }
139
140 // TODO IssueRelationshipsCleanup
141 issueFeatures, issueErr := opts.Detector.IssueFeatures()
142 if issueErr == nil && issueFeatures.IssueRelationshipsSupported {
143 lookupFields.AddValues([]string{"blockedBy", "blocking"})
144 }
145 }
146
147 opts.IO.DetectTerminalTheme()
148
149 opts.IO.StartProgressIndicator()
150 defer opts.IO.StopProgressIndicator()
151
152 lookupFields.Add("id")
153
154 issue, err := issueShared.FindIssueOrPR(httpClient, baseRepo, opts.IssueNumber, lookupFields.ToSlice())
155 if err != nil {
156 return err
157 }
158
159 if lookupFields.Contains("comments") {
160 err := preloadIssueComments(httpClient, baseRepo, issue)
161 if err != nil {
162 return err

Calls 15

NewStringSetFunction · 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
StopPagerMethod · 0.80