@@ -172,6 +172,48 @@ type MinimalIssue struct {
172172 IssueType string `json:"issue_type,omitempty"`
173173}
174174
175+ // MinimalPullRequest is the trimmed output type for pull request objects to reduce verbosity.
176+ type MinimalPullRequest struct {
177+ Number int `json:"number"`
178+ Title string `json:"title"`
179+ Body string `json:"body,omitempty"`
180+ State string `json:"state"`
181+ Draft bool `json:"draft"`
182+ Merged bool `json:"merged"`
183+ MergeableState string `json:"mergeable_state,omitempty"`
184+ HTMLURL string `json:"html_url"`
185+ User * MinimalUser `json:"user,omitempty"`
186+ Labels []string `json:"labels,omitempty"`
187+ Assignees []string `json:"assignees,omitempty"`
188+ RequestedReviewers []string `json:"requested_reviewers,omitempty"`
189+ MergedBy string `json:"merged_by,omitempty"`
190+ Head * MinimalPRBranch `json:"head,omitempty"`
191+ Base * MinimalPRBranch `json:"base,omitempty"`
192+ Additions int `json:"additions,omitempty"`
193+ Deletions int `json:"deletions,omitempty"`
194+ ChangedFiles int `json:"changed_files,omitempty"`
195+ Commits int `json:"commits,omitempty"`
196+ Comments int `json:"comments,omitempty"`
197+ CreatedAt string `json:"created_at,omitempty"`
198+ UpdatedAt string `json:"updated_at,omitempty"`
199+ ClosedAt string `json:"closed_at,omitempty"`
200+ MergedAt string `json:"merged_at,omitempty"`
201+ Milestone string `json:"milestone,omitempty"`
202+ }
203+
204+ // MinimalPRBranch is the trimmed output type for pull request branch references.
205+ type MinimalPRBranch struct {
206+ Ref string `json:"ref"`
207+ SHA string `json:"sha"`
208+ Repo * MinimalPRBranchRepo `json:"repo,omitempty"`
209+ }
210+
211+ // MinimalPRBranchRepo is the trimmed repo info nested inside a PR branch.
212+ type MinimalPRBranchRepo struct {
213+ FullName string `json:"full_name"`
214+ Description string `json:"description,omitempty"`
215+ }
216+
175217// Helper functions
176218
177219func convertToMinimalIssue (issue * github.Issue ) MinimalIssue {
@@ -239,6 +281,94 @@ func convertToMinimalIssue(issue *github.Issue) MinimalIssue {
239281 return m
240282}
241283
284+ func convertToMinimalPullRequest (pr * github.PullRequest ) MinimalPullRequest {
285+ m := MinimalPullRequest {
286+ Number : pr .GetNumber (),
287+ Title : pr .GetTitle (),
288+ Body : pr .GetBody (),
289+ State : pr .GetState (),
290+ Draft : pr .GetDraft (),
291+ Merged : pr .GetMerged (),
292+ MergeableState : pr .GetMergeableState (),
293+ HTMLURL : pr .GetHTMLURL (),
294+ User : convertToMinimalUser (pr .GetUser ()),
295+ Additions : pr .GetAdditions (),
296+ Deletions : pr .GetDeletions (),
297+ ChangedFiles : pr .GetChangedFiles (),
298+ Commits : pr .GetCommits (),
299+ Comments : pr .GetComments (),
300+ }
301+
302+ if pr .CreatedAt != nil {
303+ m .CreatedAt = pr .CreatedAt .Format (time .RFC3339 )
304+ }
305+ if pr .UpdatedAt != nil {
306+ m .UpdatedAt = pr .UpdatedAt .Format (time .RFC3339 )
307+ }
308+ if pr .ClosedAt != nil {
309+ m .ClosedAt = pr .ClosedAt .Format (time .RFC3339 )
310+ }
311+ if pr .MergedAt != nil {
312+ m .MergedAt = pr .MergedAt .Format (time .RFC3339 )
313+ }
314+
315+ for _ , label := range pr .Labels {
316+ if label != nil {
317+ m .Labels = append (m .Labels , label .GetName ())
318+ }
319+ }
320+
321+ for _ , assignee := range pr .Assignees {
322+ if assignee != nil {
323+ m .Assignees = append (m .Assignees , assignee .GetLogin ())
324+ }
325+ }
326+
327+ for _ , reviewer := range pr .RequestedReviewers {
328+ if reviewer != nil {
329+ m .RequestedReviewers = append (m .RequestedReviewers , reviewer .GetLogin ())
330+ }
331+ }
332+
333+ if mergedBy := pr .GetMergedBy (); mergedBy != nil {
334+ m .MergedBy = mergedBy .GetLogin ()
335+ }
336+
337+ if head := pr .Head ; head != nil {
338+ m .Head = convertToMinimalPRBranch (head )
339+ }
340+
341+ if base := pr .Base ; base != nil {
342+ m .Base = convertToMinimalPRBranch (base )
343+ }
344+
345+ if milestone := pr .GetMilestone (); milestone != nil {
346+ m .Milestone = milestone .GetTitle ()
347+ }
348+
349+ return m
350+ }
351+
352+ func convertToMinimalPRBranch (branch * github.PullRequestBranch ) * MinimalPRBranch {
353+ if branch == nil {
354+ return nil
355+ }
356+
357+ b := & MinimalPRBranch {
358+ Ref : branch .GetRef (),
359+ SHA : branch .GetSHA (),
360+ }
361+
362+ if repo := branch .GetRepo (); repo != nil {
363+ b .Repo = & MinimalPRBranchRepo {
364+ FullName : repo .GetFullName (),
365+ Description : repo .GetDescription (),
366+ }
367+ }
368+
369+ return b
370+ }
371+
242372func convertToMinimalProject (fullProject * github.ProjectV2 ) * MinimalProject {
243373 if fullProject == nil {
244374 return nil
0 commit comments