ephemeris_forge_forgejo/reconcile/
labels.rs1use ephemeris_forge::RepoRef;
2
3use super::Client;
4use crate::Live;
5use crate::api::{Api, ForgeError};
6use crate::config::Labels;
7use crate::operation::labels::Operation;
8
9impl<A: Api> Client<A> {
10 pub(super) async fn read_labels(
11 &self,
12 repository: &RepoRef,
13 config: Option<&Labels>,
14 live: &mut Live,
15 ) -> Result<(), ForgeError> {
16 if config.is_some() {
17 live.labels = self.api.labels(repository).await?;
18 }
19 Ok(())
20 }
21
22 pub(super) async fn apply_labels(
23 &self,
24 repository: &RepoRef,
25 operation: &Operation,
26 ) -> Result<(), ForgeError> {
27 match operation {
28 Operation::Create { body } => self.api.create_label(repository, body).await,
29 Operation::Patch { id, name: _, edit } => {
30 self.api.patch_label(repository, *id, edit).await
31 }
32 Operation::Delete { id, name: _ } => self.api.delete_label(repository, *id).await,
33 }
34 }
35}