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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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 string `json:"html_url"`
  40. HTMLPullURL string `json:"pull_request_url"`
  41. }
  42. // PullReviewComment represents a comment on a pull request review
  43. type PullReviewComment struct {
  44. ID int64 `json:"id"`
  45. Body string `json:"body"`
  46. Poster *User `json:"user"`
  47. Resolver *User `json:"resolver"`
  48. ReviewID int64 `json:"pull_request_review_id"`
  49. // swagger:strfmt date-time
  50. Created time.Time `json:"created_at"`
  51. // swagger:strfmt date-time
  52. Updated time.Time `json:"updated_at"`
  53. Path string `json:"path"`
  54. CommitID string `json:"commit_id"`
  55. OrigCommitID string `json:"original_commit_id"`
  56. DiffHunk string `json:"diff_hunk"`
  57. LineNum uint64 `json:"position"`
  58. OldLineNum uint64 `json:"original_position"`
  59. HTMLURL string `json:"html_url"`
  60. HTMLPullURL string `json:"pull_request_url"`
  61. }
  62. // CreatePullReviewOptions are options to create a pull review
  63. type CreatePullReviewOptions struct {
  64. Event ReviewStateType `json:"event"`
  65. Body string `json:"body"`
  66. CommitID string `json:"commit_id"`
  67. Comments []CreatePullReviewComment `json:"comments"`
  68. }
  69. // CreatePullReviewComment represent a review comment for creation api
  70. type CreatePullReviewComment struct {
  71. // the tree path
  72. Path string `json:"path"`
  73. Body string `json:"body"`
  74. // if comment to old file line or 0
  75. OldLineNum int64 `json:"old_position"`
  76. // if comment to new file line or 0
  77. NewLineNum int64 `json:"new_position"`
  78. }
  79. // SubmitPullReviewOptions are options to submit a pending pull review
  80. type SubmitPullReviewOptions struct {
  81. Event ReviewStateType `json:"event"`
  82. Body string `json:"body"`
  83. }
  84. // DismissPullReviewOptions are options to dismiss a pull review
  85. type DismissPullReviewOptions struct {
  86. Message string `json:"message"`
  87. Priors bool `json:"priors"`
  88. }
  89. // PullReviewRequestOptions are options to add or remove pull review requests
  90. type PullReviewRequestOptions struct {
  91. Reviewers []string `json:"reviewers"`
  92. TeamReviewers []string `json:"team_reviewers"`
  93. }