Skip to main content

nominal_api/conjure/objects/scout/versioning/api/
commit_request.rs

1#[derive(
2    Debug,
3    Clone,
4    conjure_object::serde::Serialize,
5    conjure_object::serde::Deserialize,
6    PartialEq,
7    Eq,
8    PartialOrd,
9    Ord,
10    Hash
11)]
12#[serde(crate = "conjure_object::serde")]
13#[conjure_object::private::staged_builder::staged_builder]
14#[builder(crate = conjure_object::private::staged_builder, update, inline)]
15pub struct CommitRequest {
16    #[serde(rename = "newCommit")]
17    new_commit: super::CommitId,
18    #[builder(default, into)]
19    #[serde(
20        rename = "mergeParentCommit",
21        skip_serializing_if = "Option::is_none",
22        default
23    )]
24    merge_parent_commit: Option<super::CommitId>,
25    #[builder(into)]
26    #[serde(rename = "message")]
27    message: String,
28    #[builder(default, into)]
29    #[serde(rename = "latestCommit", skip_serializing_if = "Option::is_none", default)]
30    latest_commit: Option<super::CommitId>,
31}
32impl CommitRequest {
33    /// Constructs a new instance of the type.
34    #[inline]
35    pub fn new(new_commit: super::CommitId, message: impl Into<String>) -> Self {
36        Self::builder().new_commit(new_commit).message(message).build()
37    }
38    #[inline]
39    pub fn new_commit(&self) -> &super::CommitId {
40        &self.new_commit
41    }
42    /// If present, this existing commit will be the merge parent
43    /// of the new commit. It will be made permanent if not already,
44    /// to prevent the merge parent from being compacted.
45    #[inline]
46    pub fn merge_parent_commit(&self) -> Option<&super::CommitId> {
47        self.merge_parent_commit.as_ref().map(|o| &*o)
48    }
49    #[inline]
50    pub fn message(&self) -> &str {
51        &*self.message
52    }
53    #[inline]
54    pub fn latest_commit(&self) -> Option<&super::CommitId> {
55        self.latest_commit.as_ref().map(|o| &*o)
56    }
57}