gitea源码

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. // Copyright 2016 The Gogs Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package structs
  4. import (
  5. "time"
  6. )
  7. // PullRequest represents a pull request
  8. type PullRequest struct {
  9. // The unique identifier of the pull request
  10. ID int64 `json:"id"`
  11. // The API URL of the pull request
  12. URL string `json:"url"`
  13. // The pull request number
  14. Index int64 `json:"number"`
  15. // The user who created the pull request
  16. Poster *User `json:"user"`
  17. // The title of the pull request
  18. Title string `json:"title"`
  19. // The description body of the pull request
  20. Body string `json:"body"`
  21. // The labels attached to the pull request
  22. Labels []*Label `json:"labels"`
  23. // The milestone associated with the pull request
  24. Milestone *Milestone `json:"milestone"`
  25. // The primary assignee of the pull request
  26. Assignee *User `json:"assignee"`
  27. // The list of users assigned to the pull request
  28. Assignees []*User `json:"assignees"`
  29. // The users requested to review the pull request
  30. RequestedReviewers []*User `json:"requested_reviewers"`
  31. // The teams requested to review the pull request
  32. RequestedReviewersTeams []*Team `json:"requested_reviewers_teams"`
  33. // The current state of the pull request
  34. State StateType `json:"state"`
  35. // Whether the pull request is a draft
  36. Draft bool `json:"draft"`
  37. // Whether the pull request conversation is locked
  38. IsLocked bool `json:"is_locked"`
  39. // The number of comments on the pull request
  40. Comments int `json:"comments"`
  41. // number of review comments made on the diff of a PR review (not including comments on commits or issues in a PR)
  42. ReviewComments int `json:"review_comments,omitempty"`
  43. // The number of lines added in the pull request
  44. Additions *int `json:"additions,omitempty"`
  45. // The number of lines deleted in the pull request
  46. Deletions *int `json:"deletions,omitempty"`
  47. // The number of files changed in the pull request
  48. ChangedFiles *int `json:"changed_files,omitempty"`
  49. // The HTML URL to view the pull request
  50. HTMLURL string `json:"html_url"`
  51. // The URL to download the diff patch
  52. DiffURL string `json:"diff_url"`
  53. // The URL to download the patch file
  54. PatchURL string `json:"patch_url"`
  55. // Whether the pull request can be merged
  56. Mergeable bool `json:"mergeable"`
  57. // Whether the pull request has been merged
  58. HasMerged bool `json:"merged"`
  59. // swagger:strfmt date-time
  60. Merged *time.Time `json:"merged_at"`
  61. // The SHA of the merge commit
  62. MergedCommitID *string `json:"merge_commit_sha"`
  63. // The user who merged the pull request
  64. MergedBy *User `json:"merged_by"`
  65. // Whether maintainers can edit the pull request
  66. AllowMaintainerEdit bool `json:"allow_maintainer_edit"`
  67. // Information about the base branch
  68. Base *PRBranchInfo `json:"base"`
  69. // Information about the head branch
  70. Head *PRBranchInfo `json:"head"`
  71. // The merge base commit SHA
  72. MergeBase string `json:"merge_base"`
  73. // swagger:strfmt date-time
  74. Deadline *time.Time `json:"due_date"`
  75. // swagger:strfmt date-time
  76. Created *time.Time `json:"created_at"`
  77. // swagger:strfmt date-time
  78. Updated *time.Time `json:"updated_at"`
  79. // swagger:strfmt date-time
  80. Closed *time.Time `json:"closed_at"`
  81. // The pin order for the pull request
  82. PinOrder int `json:"pin_order"`
  83. }
  84. // PRBranchInfo information about a branch
  85. type PRBranchInfo struct {
  86. // The display name of the branch
  87. Name string `json:"label"`
  88. // The git reference of the branch
  89. Ref string `json:"ref"`
  90. // The commit SHA of the branch head
  91. Sha string `json:"sha"`
  92. // The unique identifier of the repository
  93. RepoID int64 `json:"repo_id"`
  94. // The repository information
  95. Repository *Repository `json:"repo"`
  96. }
  97. // ListPullRequestsOptions options for listing pull requests
  98. type ListPullRequestsOptions struct {
  99. // The page number for pagination
  100. Page int `json:"page"`
  101. // The state filter for pull requests
  102. State string `json:"state"`
  103. }
  104. // CreatePullRequestOption options when creating a pull request
  105. type CreatePullRequestOption struct {
  106. // The head branch for the pull request, it could be a branch name on the base repository or
  107. // a form like `<username>:<branch>` which refers to the user's fork repository's branch.
  108. Head string `json:"head" binding:"Required"`
  109. // The base branch for the pull request
  110. Base string `json:"base" binding:"Required"`
  111. // The title of the pull request
  112. Title string `json:"title" binding:"Required"`
  113. // The description body of the pull request
  114. Body string `json:"body"`
  115. // The primary assignee username
  116. Assignee string `json:"assignee"`
  117. // The list of assignee usernames
  118. Assignees []string `json:"assignees"`
  119. // The milestone ID to assign to the pull request
  120. Milestone int64 `json:"milestone"`
  121. // The list of label IDs to assign to the pull request
  122. Labels []int64 `json:"labels"`
  123. // swagger:strfmt date-time
  124. Deadline *time.Time `json:"due_date"`
  125. // The list of reviewer usernames
  126. Reviewers []string `json:"reviewers"`
  127. // The list of team reviewer names
  128. TeamReviewers []string `json:"team_reviewers"`
  129. }
  130. // EditPullRequestOption options when modify pull request
  131. type EditPullRequestOption struct {
  132. // The new title for the pull request
  133. Title string `json:"title"`
  134. // The new description body for the pull request
  135. Body *string `json:"body"`
  136. // The new base branch for the pull request
  137. Base string `json:"base"`
  138. // The new primary assignee username
  139. Assignee string `json:"assignee"`
  140. // The new list of assignee usernames
  141. Assignees []string `json:"assignees"`
  142. // The new milestone ID for the pull request
  143. Milestone int64 `json:"milestone"`
  144. // The new list of label IDs for the pull request
  145. Labels []int64 `json:"labels"`
  146. // The new state for the pull request
  147. State *string `json:"state"`
  148. // swagger:strfmt date-time
  149. Deadline *time.Time `json:"due_date"`
  150. // Whether to remove the current deadline
  151. RemoveDeadline *bool `json:"unset_due_date"`
  152. // Whether to allow maintainer edits
  153. AllowMaintainerEdit *bool `json:"allow_maintainer_edit"`
  154. }
  155. // ChangedFile store information about files affected by the pull request
  156. type ChangedFile struct {
  157. // The name of the changed file
  158. Filename string `json:"filename"`
  159. // The previous filename if the file was renamed
  160. PreviousFilename string `json:"previous_filename,omitempty"`
  161. // The status of the file change (added, modified, deleted, etc.)
  162. Status string `json:"status"`
  163. // The number of lines added to the file
  164. Additions int `json:"additions"`
  165. // The number of lines deleted from the file
  166. Deletions int `json:"deletions"`
  167. // The total number of changes to the file
  168. Changes int `json:"changes"`
  169. // The HTML URL to view the file changes
  170. HTMLURL string `json:"html_url,omitempty"`
  171. // The API URL to get the file contents
  172. ContentsURL string `json:"contents_url,omitempty"`
  173. // The raw URL to download the file
  174. RawURL string `json:"raw_url,omitempty"`
  175. }