1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
/*
* Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
//! A set of review comments on a pull/merge request.
use serde::{Deserialize, Serialize};
use crate::Reaction;
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
#[serde(rename_all = "UPPERCASE")]
/// State of the review.
pub enum ReviewState {
Pending,
Approved,
ChangesRequested,
Commented,
}
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
/// A set of review comments on a pull/merge request.
pub struct Review {
/// Unique identifier of the review
pub index: usize,
/// Unique identifier of the pull/merge request targeted by the review.
pub issue_index: usize,
/// Unique identifer of review author.
pub reviewer_id: usize,
/// True if a positive review counts to reach the required threshold.
pub official: Option<bool>,
/// SHA of the commit targeted by the review.
pub commit_id: String,
/// Cover message of the review.
pub content: String,
// TODO: add validation for format "date-time"
/// Creation time
pub created_at: String,
/// State of the review.
pub state: ReviewState,
/// Review comments inserted on a specific line of the commit.
pub comments: Option<Vec<ReviewComment>>,
}
/// A comment in the context of a review.
#[derive(Clone, Debug, Serialize, Deserialize, Eq, PartialEq)]
pub struct ReviewComment {
/// Unique identifier of the review comment.
pub index: usize,
/// Unique identifier of the review comment replied to.
pub in_reply_to: usize,
/// The text of the review comment
pub content: String,
/// The relative path to the file that necessitates a comment.
pub tree_path: String,
/// The hunk being commented on, which is the same as the patch only in a different format.
pub diff_hunk: String,
/// The patch being commented on, which is the same as the diff_hunk only in a different
/// format.
pub patch: String,
/// Equals the number of lines down from the first '@@' hunk header in the file you want to add
/// a comment. The line just below the '@@' line is position 1, the next line is position 2,
/// and so on. The position in the diff continues to increase through lines of whitespace and
/// additional hunks until the beginning of a new file.",
pub position: usize,
/// The line number of the comment in the tree_path
pub line: usize,
/// The SHA of the commit needing a comment. Not using the latest commit SHA may render your
/// comment outdated if a subsequent commit modifies the line you specify as the position.
pub commit_id: String,
/// Unique identifier of the user who authored the comment.
pub poster_id: usize,
// TODO: add validation for format "date-time"
/// Creation time
pub created_at: String,
// TODO: add validation for format "date-time"
/// Last update time
pub updated_at: String,
/// List of reactions
pub reactions: Option<Vec<Reaction>>,
}