Skip to main content

ephemeris_forge_github/reconcile/
custom_properties.rs

1use std::collections::BTreeMap;
2
3use ephemeris_forge::RepoRef;
4
5use super::Client;
6use crate::api::{Api, ForgeError};
7use crate::operation::custom_properties::Operation;
8use crate::{Live, PropertyValue};
9
10impl<A: Api> Client<A> {
11    pub(super) async fn read_custom_properties(
12        &self,
13        repository: &RepoRef,
14        config: Option<&BTreeMap<String, PropertyValue>>,
15        live: &mut Live,
16    ) -> Result<(), ForgeError> {
17        if config.is_some() {
18            live.custom_properties = self.api.custom_property_values(repository).await?;
19        }
20        Ok(())
21    }
22
23    pub(super) async fn apply_custom_properties(
24        &self,
25        repository: &RepoRef,
26        operation: &Operation,
27    ) -> Result<(), ForgeError> {
28        match operation {
29            Operation::Set(entries) => {
30                self.api
31                    .set_custom_property_values(repository, entries)
32                    .await
33            }
34        }
35    }
36}