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
// Copyright (C) 2023 Aravinth Manivannan <realaravinth@batsense.net>
// SPDX-FileCopyrightText: 2023 Aravinth Manivannan <realaravinth@batsense.net>
//
// 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<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,
}