Repository: web3infra-foundation/mega (language: rust)

Issue:
Can't push all tags to third-part folder
When importing a repo into the `third-part`, you can't push tags with the `git push --tags` command.

```bash
$ git clone https://gitee.com/openeuler/bishengjdk-8
$ cd bishengjdk-8
$ git remote add mega https://git.gitmega.com/third-part/openeuler/bishengjdk-8

$ git push --all mega
Enumerating objects: 72460, done.
Counting objects: 100% (72460/72460), done.
Delta compression using up to 16 threads
Compressing objects: 100% (33527/33527), done.
Writing objects: 100% (72460/72460), 114.11 MiB | 3.20 MiB/s, done.
Total 72460 (delta 35162), reused 72460 (delta 35162), pack-reused 0
To https://git.gitmega.com/third-part/openeuler/bishengjdk-8
 * [new branch]          master -> master

$ git push --tags mega
Enumerating objects: 27, done.
Counting objects: 100% (27/27), done.
Delta compression using up to 16 threads
Compressing objects: 100% (27/27), done.
Writing objects: 100% (27/27), 3.46 KiB | 3.46 MiB/s, done.
Total 27 (delta 0), reused 27 (delta 0), pack-reused 0
error: RPC failed; HTTP 502 curl 22 The requested URL returned error: 502
send-pack: unexpected disconnect while reading sideband packet
fatal: the remote end hung up unexpectedly
Everything up-to-date
```


Discussion / hints:

Fix patch:
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<SHA1, Tree> = 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()


Test patch: