use serde::{Deserialize, Serialize}; use time::OffsetDateTime; use crate::service::GitService; use crate::share::errors::GitError; use crate::share::identity::load_identity; #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct SignatureDto { pub name: String, pub email: String, pub when: OffsetDateTime, } #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, utoipa::ToSchema)] #[serde(rename_all = "lowercase")] pub enum ObjectKind { Merge, Squash, } #[derive(Debug, Clone, Serialize, Deserialize, utoipa::ToSchema)] pub struct FileEntryDto { pub path: String, pub content: Vec, pub executable: bool, } #[derive(Debug, Clone, Serialize, utoipa::ToSchema)] pub struct WriteObjectResultDto { pub id: String, } impl GitService { pub async fn caller_signature( &self, caller: i64, when: OffsetDateTime, ) -> Result { let ident = load_identity(&self.state, caller).await?; Ok(SignatureDto { name: ident.name, email: ident.email, when, }) } pub async fn write_blob( &self, _space_name: String, _repo_name: String, _data: Vec, ) -> Result { Err(GitError::Unimplemented( "writing git objects requires a KenShell ContentWriteService", )) } pub async fn write_tree_from_files( &self, _space_name: String, _repo_name: String, _files: Vec, ) -> Result { Err(GitError::Unimplemented( "writing git trees requires a KenShell ContentWriteService", )) } #[allow(clippy::too_many_arguments)] pub async fn commit_object( &self, _space_name: String, _repo_name: String, _kind: ObjectKind, _parents: Vec, _tree: String, _message: String, _author: SignatureDto, _committer: SignatureDto, ) -> Result { Err(GitError::Unimplemented( "writing git commits requires a KenShell ContentWriteService", )) } }