f3-rs/src/review.rs
Aravinth Manivannan fd9221ee58
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
feat: define Review
2023-01-03 14:01:51 +05:30

112 lines
3.6 KiB
Rust

/*
* 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>>,
}