From 1844078a47bb4c103f960831ee4ca2f20abce68f Mon Sep 17 00:00:00 2001 From: "benjamin.747" Date: Fri, 27 Dec 2024 11:15:26 +0800 Subject: [PATCH] fix push all tags to third-part folder --- ceres/src/pack/import_repo.rs | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/ceres/src/pack/import_repo.rs b/ceres/src/pack/import_repo.rs index 5b286ea4..08b064a1 100644 --- a/ceres/src/pack/import_repo.rs +++ b/ceres/src/pack/import_repo.rs @@ -13,7 +13,7 @@ use futures::{future::join_all, StreamExt}; use tokio::sync::mpsc; use tokio_stream::wrappers::ReceiverStream; -use callisto::{mega_tree, raw_blob}; +use callisto::{db_enums::RefType, mega_tree, raw_blob}; use common::errors::MegaError; use jupiter::{context::Context, storage::batch_save_model}; use mercury::{ @@ -204,10 +204,7 @@ impl PackHandler for ImportRepo { } } - let want_tree_ids = want_commits - .iter() - .map(|c| c.tree_id.to_string()) - .collect(); + let want_tree_ids = want_commits.iter().map(|c| c.tree_id.to_string()).collect(); let want_trees: HashMap = storage .get_trees_by_hashes(self.repo.repo_id, want_tree_ids) .await @@ -342,6 +339,16 @@ impl PackHandler for ImportRepo { impl ImportRepo { // attach import repo to monorepo parent tree async fn attach_to_monorepo_parent(&self) -> Result<(), GitError> { + let iter = self + .command_list + .clone() + .into_iter() + .find(|c| c.ref_type == RefType::Branch); + if iter.is_none() { + return Ok(()); + } + let commit_id = iter.unwrap().new_id; + let path = PathBuf::from(self.repo.repo_path.clone()); let mono_api_service = MonoApiService { context: self.context.clone(), @@ -350,12 +357,11 @@ impl ImportRepo { let save_trees = mono_api_service.search_and_create_tree(&path).await?; let mut root_ref = storage.get_ref("/").await.unwrap().unwrap(); - let commit_id = &self.command_list.first().unwrap().new_id; let latest_commit: Commit = self .context .services .git_db_storage - .get_commit_by_hash(self.repo.repo_id, commit_id) + .get_commit_by_hash(self.repo.repo_id, &commit_id) .await .unwrap() .unwrap()