// Copyright (C) 2023 Aravinth Manivannan // SPDX-FileCopyrightText: 2023 Aravinth Manivannan // // SPDX-License-Identifier: MIT //! 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, /// 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, /// List of labels. pub labels: Option>, /// List of reactions pub reactions: Option>, /// List of assignees. pub assignees: Option>, /// 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, /// The SHA of the merge commit pub merged_commit_sha: Option, /// The changes proposed in the pull request. pub head: Option, /// The branch where the pull request changes in the head are to be merged. pub base: Option, } /// 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, /// 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, }