feat: define PullRequest
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
a8f9e5a52a
commit
f42f7005ee
2 changed files with 112 additions and 0 deletions
|
@ -26,6 +26,7 @@ pub mod issue;
|
||||||
pub mod label;
|
pub mod label;
|
||||||
pub mod milestone;
|
pub mod milestone;
|
||||||
pub mod project;
|
pub mod project;
|
||||||
|
pub mod pullrequest;
|
||||||
pub mod reaction;
|
pub mod reaction;
|
||||||
pub mod repository;
|
pub mod repository;
|
||||||
pub mod topic;
|
pub mod topic;
|
||||||
|
@ -37,6 +38,7 @@ pub use issue::Issue;
|
||||||
pub use label::Label;
|
pub use label::Label;
|
||||||
pub use milestone::Milestone;
|
pub use milestone::Milestone;
|
||||||
pub use project::Project;
|
pub use project::Project;
|
||||||
|
pub use pullrequest::PullRequest;
|
||||||
pub use reaction::Reaction;
|
pub use reaction::Reaction;
|
||||||
pub use repository::Repository;
|
pub use repository::Repository;
|
||||||
pub use topic::Topic;
|
pub use topic::Topic;
|
||||||
|
|
110
src/pullrequest.rs
Normal file
110
src/pullrequest.rs
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
/*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
//! Pull requests associated to a repository within a forge (Gitea, GitLab, etc.)
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::{OpenCloseState, Reaction};
|
||||||
|
|
||||||
|
/// Pull requests associated to a repository within a forge (Gitea, GitLab, etc.)
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize, Default, Eq, PartialEq)]
|
||||||
|
pub struct PullRequest {
|
||||||
|
/// Unique identifier, relative to the repository
|
||||||
|
pub index: usize,
|
||||||
|
|
||||||
|
/// Unique identifier of the user who authored the pull request.
|
||||||
|
pub poster_id: usize,
|
||||||
|
|
||||||
|
/// Short description displayed as the title.
|
||||||
|
pub title: String,
|
||||||
|
|
||||||
|
/// Long, multiline, description
|
||||||
|
pub content: String,
|
||||||
|
|
||||||
|
/// Name of the milestone
|
||||||
|
pub milestone: Option<String>,
|
||||||
|
|
||||||
|
/// state of the pull request
|
||||||
|
pub state: OpenCloseState,
|
||||||
|
|
||||||
|
/// A locked pull request issue can only be modified by privileged users
|
||||||
|
pub is_locked: bool,
|
||||||
|
|
||||||
|
// TODO: add validation for format "date-time"
|
||||||
|
/// Creation time
|
||||||
|
pub created: String,
|
||||||
|
|
||||||
|
// TODO: add validation for format "date-time"
|
||||||
|
/// Last update time
|
||||||
|
pub updated: String,
|
||||||
|
|
||||||
|
// TODO: add validation for format "date-time"
|
||||||
|
/// The last time 'state' changed to 'closed'
|
||||||
|
pub closed: Option<String>,
|
||||||
|
|
||||||
|
/// List of labels.
|
||||||
|
pub labels: Option<Vec<String>>,
|
||||||
|
|
||||||
|
/// List of reactions
|
||||||
|
pub reactions: Option<Vec<Reaction>>,
|
||||||
|
|
||||||
|
/// List of assignees.
|
||||||
|
pub assignees: Option<Vec<String>>,
|
||||||
|
|
||||||
|
/// URL from which the patch of the pull request can be retrieved.
|
||||||
|
pub patch_url: String,
|
||||||
|
|
||||||
|
/// True if the pull request was merged
|
||||||
|
pub merged: bool,
|
||||||
|
|
||||||
|
// TODO: add validation for format "date-time"
|
||||||
|
/// The time when the pull request was merged.
|
||||||
|
pub merged_time: Option<String>,
|
||||||
|
|
||||||
|
/// The SHA of the merge commit
|
||||||
|
pub merged_commit_sha: Option<String>,
|
||||||
|
|
||||||
|
/// The changes proposed in the pull request.
|
||||||
|
pub head: Option<PullRequestRef>,
|
||||||
|
|
||||||
|
/// The branch where the pull request changes in the head are to be merged.
|
||||||
|
pub base: Option<PullRequestRef>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// PullRequest reference to a commit
|
||||||
|
/// The location of a commit, including the URL of the repository where it can be found
|
||||||
|
#[derive(Clone, Debug, Serialize, Deserialize, Default, Eq, PartialEq)]
|
||||||
|
pub struct PullRequestRef {
|
||||||
|
/// URL of the repository where the commit is located.
|
||||||
|
pub clone_url: String,
|
||||||
|
|
||||||
|
/// Target branch in the repository.
|
||||||
|
///
|
||||||
|
/// NOTE: Actual property is called "ref" but it is a keyword in Rust so we are using
|
||||||
|
/// "reference". However, "reference" will automatically be renamed to "ref" while serializing
|
||||||
|
/// and vice versa
|
||||||
|
#[serde(rename(serialize = "ref", deserialize = "ref"))]
|
||||||
|
pub reference: Option<String>,
|
||||||
|
|
||||||
|
/// SHA of the commit
|
||||||
|
pub sha: String,
|
||||||
|
|
||||||
|
/// Name of the project that contains the git repository.
|
||||||
|
pub repo_name: String,
|
||||||
|
|
||||||
|
/// Name of the user or organization that contains the project.
|
||||||
|
pub owner_name: String,
|
||||||
|
}
|
Loading…
Reference in a new issue