feat: define Review
ci/woodpecker/push/woodpecker Pipeline was successful Details

This commit is contained in:
Aravinth Manivannan 2023-01-03 14:01:51 +05:30
parent 1f1704bf76
commit fd9221ee58
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
2 changed files with 115 additions and 1 deletions

View File

@ -30,6 +30,7 @@ pub mod pullrequest;
pub mod reaction;
pub mod release;
pub mod repository;
pub mod review;
pub mod topic;
pub mod user;
@ -41,8 +42,9 @@ pub use milestone::Milestone;
pub use project::Project;
pub use pullrequest::PullRequest;
pub use reaction::Reaction;
pub use release::ReleaseAsset;
pub use release::{Release, ReleaseAsset};
pub use repository::Repository;
pub use review::{Review, ReviewComment, ReviewState};
pub use topic::Topic;
pub use user::User;

112
src/review.rs Normal file
View File

@ -0,0 +1,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>>,
}