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.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. 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. CodeCommentsCount int `json:"comments_count"`
  34. // swagger:strfmt date-time
  35. Submitted time.Time `json:"submitted_at"`
  36. HTMLURL string `json:"html_url"`
  37. HTMLPullURL string `json:"pull_request_url"`
  38. }
  39. // PullReviewComment represents a comment on a pull request review
  40. type PullReviewComment struct {
  41. ID int64 `json:"id"`
  42. Body string `json:"body"`
  43. Reviewer *User `json:"user"`
  44. ReviewID int64 `json:"pull_request_review_id"`
  45. // swagger:strfmt date-time
  46. Created time.Time `json:"created_at"`
  47. // swagger:strfmt date-time
  48. Updated time.Time `json:"updated_at"`
  49. Path string `json:"path"`
  50. CommitID string `json:"commit_id"`
  51. OrigCommitID string `json:"original_commit_id"`
  52. DiffHunk string `json:"diff_hunk"`
  53. LineNum uint64 `json:"position"`
  54. OldLineNum uint64 `json:"original_position"`
  55. HTMLURL string `json:"html_url"`
  56. HTMLPullURL string `json:"pull_request_url"`
  57. }
  58. // CreatePullReviewOptions are options to create a pull review
  59. type CreatePullReviewOptions struct {
  60. Event ReviewStateType `json:"event"`
  61. Body string `json:"body"`
  62. CommitID string `json:"commit_id"`
  63. Comments []CreatePullReviewComment `json:"comments"`
  64. }
  65. // CreatePullReviewComment represent a review comment for creation api
  66. type CreatePullReviewComment struct {
  67. // the tree path
  68. Path string `json:"path"`
  69. Body string `json:"body"`
  70. // if comment to old file line or 0
  71. OldLineNum int64 `json:"old_position"`
  72. // if comment to new file line or 0
  73. NewLineNum int64 `json:"new_position"`
  74. }
  75. // SubmitPullReviewOptions are options to submit a pending pull review
  76. type SubmitPullReviewOptions struct {
  77. Event ReviewStateType `json:"event"`
  78. Body string `json:"body"`
  79. }