feat(lib/git): update content, hooks, patches, and pipelines services
ZhenYi committed
Modified lib/git/src/service/content.rs lib/git/src/service/content.rs +3 −4 View lib/git/src/service/content.rs
@@ -105,7 +105,7 @@
105105 .map_err(|e| GitError::Internal(format!("write blob `{path}` failed: {e}")))?;
106106 blobs.insert(path, id.into());
107107 }
108 let tree_oid = build_tree_recursive(&repo, "", &blobs).await?;
108 let tree_oid = build_tree_recursive(&repo, "", &blobs)?;
109109 Ok(WriteObjectResultDto {
110110 id: tree_oid.to_string(),
111111 })
@@ -230,17 +230,16 @@
230230 write_tree(&object)
231231}
232232
233async fn build_tree_recursive(
233fn build_tree_recursive(
234234 repo: &gix::Repository,
235235 prefix: &str,
236236 blobs: &BTreeMap<String, ObjectId>,
237237) -> Result<ObjectId, GitError> {
238 let blobs = blobs.clone();
239238 let objects = repo.objects.clone();
240239 let mut write_tree = move |data: &[u8]| -> Result<ObjectId, GitError> {
241240 objects
242241 .write_buf(Kind::Tree, data)
243242 .map_err(|e| GitError::Internal(format!("write tree failed: {e}")))
244243 };
245 build_tree_recursive_sync(prefix, &blobs, &mut write_tree)
244 build_tree_recursive_sync(prefix, blobs, &mut write_tree)
246245}
Modified lib/git/src/service/hooks.rs lib/git/src/service/hooks.rs +2 −2 View lib/git/src/service/hooks.rs
@@ -14,14 +14,14 @@
1414 MergeRequest,
1515}
1616
17#[derive(Debug, Clone, Serialize)]
17#[derive(Debug, Clone, Serialize, Deserialize)]
1818pub struct HookRefDto {
1919 pub name: String,
2020 pub old_oid: Option<String>,
2121 pub new_oid: Option<String>,
2222}
2323
24#[derive(Debug, Clone, Serialize)]
24#[derive(Debug, Clone, Serialize, Deserialize)]
2525pub struct HookEventDto {
2626 pub kind: HookEventKind,
2727 pub repo_id: String,
Modified lib/git/src/service/patches.rs lib/git/src/service/patches.rs +1 −0 View lib/git/src/service/patches.rs
@@ -5,6 +5,7 @@
55
66use crate::service::GitService;
77use crate::share::errors::{GitError, map_baby};
8#[derive(Debug, Clone, Serialize)]
89pub struct PatchDto {
910 pub content: String,
1011 pub size: i64,
Modified lib/git/src/service/pipelines.rs lib/git/src/service/pipelines.rs +3 −3 View lib/git/src/service/pipelines.rs
@@ -1,11 +1,11 @@
1use serde::Serialize;
1use serde::{Deserialize, Serialize};
22use time::OffsetDateTime;
33use uuid::Uuid;
44
55use crate::service::GitService;
66use crate::share::errors::GitError;
77
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize)]
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
99#[serde(rename_all = "lowercase")]
1010pub enum CommitStatusState {
1111 Pending,
@@ -25,7 +25,7 @@
2525 pub creator: Option<String>,
2626}
2727
28#[derive(Debug, Clone, Serialize)]
28#[derive(Debug, Clone, Serialize, Deserialize)]
2929pub struct JobDto {
3030 pub id: String,
3131 pub name: String,