gitea源码

pull_review.go 3.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // Copyright 2020 The Gitea Authors. All rights reserved.
  2. // SPDX-License-Identifier: MIT
  3. package structs
  4. import (
  5. "time"
  6. )
  7. // ReviewStateType review state type
  8. type ReviewStateType string
  9. const (
  10. // ReviewStateApproved pr is approved
  11. ReviewStateApproved ReviewStateType = "APPROVED"
  12. // ReviewStatePending pr state is pending
  13. ReviewStatePending ReviewStateType = "PENDING"
  14. // ReviewStateComment is a comment review
  15. ReviewStateComment ReviewStateType = "COMMENT"
  16. // ReviewStateRequestChanges changes for pr are requested
  17. ReviewStateRequestChanges ReviewStateType = "REQUEST_CHANGES"
  18. // ReviewStateRequestReview review is requested from user
  19. ReviewStateRequestReview ReviewStateType = "REQUEST_REVIEW"
  20. // ReviewStateUnknown state of pr is unknown
  21. ReviewStateUnknown ReviewStateType = ""
  22. )
  23. // PullReview represents a pull request review
  24. type PullReview struct {
  25. ID int64 `json:"id"`
  26. Reviewer *User `json:"user"`
  27. ReviewerTeam *Team `json:"team"`
  28. State ReviewStateType `json:"state"`
  29. Body string `json:"body"`
  30. CommitID string `json:"commit_id"`
  31. Stale bool `json:"stale"`
  32. Official bool `json:"official"`
  33. Dismissed bool `json:"dismissed"`
  34. CodeCommentsCount int `json:"comments_count"`
  35. // swagger:strfmt date-time
  36. Submitted time.Time `json:"submitted_at"`
  37. // swagger:strfmt date-time
  38. Updated time.Time `json:"updated_at"`
  39. // HTMLURL is the web URL for viewing the review
  40. HTMLURL string `json:"html_url"`
  41. // HTMLPullURL is the web URL for the pull request
  42. HTMLPullURL string `json:"pull_request_url"`
  43. }
  44. // PullReviewComment represents a comment on a pull request review
  45. type PullReviewComment struct {
  46. ID int64 `json:"id"`
  47. Body string `json:"body"`
  48. Poster *User `json:"user"`
  49. Resolver *User `json:"resolver"`
  50. ReviewID int64 `json:"pull_request_review_id"`
  51. // swagger:strfmt date-time
  52. Created time.Time `json:"created_at"`
  53. // swagger:strfmt date-time
  54. Updated time.Time `json:"updated_at"`
  55. Path string `json:"path"`
  56. CommitID string `json:"commit_id"`
  57. OrigCommitID string `json:"original_commit_id"`
  58. DiffHunk string `json:"diff_hunk"`
  59. LineNum uint64 `json:"position"`
  60. OldLineNum uint64 `json:"original_position"`
  61. HTMLURL string `json:"html_url"`
  62. HTMLPullURL string `json:"pull_request_url"`
  63. }
  64. // CreatePullReviewOptions are options to create a pull review
  65. type CreatePullReviewOptions struct {
  66. Event ReviewStateType `json:"event"`
  67. Body string `json:"body"`
  68. CommitID string `json:"commit_id"`
  69. Comments []CreatePullReviewComment `json:"comments"`
  70. }
  71. // CreatePullReviewComment represent a review comment for creation api
  72. type CreatePullReviewComment struct {
  73. // the tree path
  74. Path string `json:"path"`
  75. Body string `json:"body"`
  76. // if comment to old file line or 0
  77. OldLineNum int64 `json:"old_position"`
  78. // if comment to new file line or 0
  79. NewLineNum int64 `json:"new_position"`
  80. }
  81. // SubmitPullReviewOptions are options to submit a pending pull review
  82. type SubmitPullReviewOptions struct {
  83. Event ReviewStateType `json:"event"`
  84. Body string `json:"body"`
  85. }
  86. // DismissPullReviewOptions are options to dismiss a pull review
  87. type DismissPullReviewOptions struct {
  88. Message string `json:"message"`
  89. Priors bool `json:"priors"`
  90. }
  91. // PullReviewRequestOptions are options to add or remove pull review requests
  92. type PullReviewRequestOptions struct {
  93. Reviewers []string `json:"reviewers"`
  94. TeamReviewers []string `json:"team_reviewers"`
  95. }