You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pull_review.go 3.5KB

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