diff --git a/ceres/src/api_service/mono_api_service.rs b/ceres/src/api_service/mono_api_service.rs index 582595a3c..561296a12 100644 --- a/ceres/src/api_service/mono_api_service.rs +++ b/ceres/src/api_service/mono_api_service.rs @@ -97,7 +97,7 @@ impl ApiHandler for MonoApiService { let commit = Commit::from_tree_id( p_tree.id, vec![SHA1::from_str(&refs.ref_commit_hash).unwrap()], - &format!("create file {} commit", file_info.name), + &format!("\ncreate file {} commit", file_info.name), ); // Update the parent tree with the new commit @@ -363,55 +363,57 @@ impl MonoApiService { let base_path = self.context.config.base_dir.clone(); env::set_current_dir(&base_path).unwrap(); let clone_path = base_path.join(mr_link); - if fs::exists(&clone_path).unwrap() { - fs::remove_dir_all(&clone_path).unwrap(); + if !fs::exists(&clone_path).unwrap() { + // fs::remove_dir_all(&clone_path).unwrap(); + Command::new("mkdir") + .arg(mr_link) + .output() + .await + .expect("Failed to mkdir"); + // cd mr + env::set_current_dir(&clone_path).unwrap(); + // libra init + Command::new("libra") + .arg("init") + .output() + .await + .expect("Failed to execute libra init"); + // libra remote add origin http://localhost:8000/project + Command::new("libra") + .arg("remote") + .arg("add") + .arg("origin") + .arg(format!("http://localhost:8000{}", mr.path)) + .output() + .await + .expect("Failed to execute libra remote add"); + // libra fetch origin QB0X1X1K + Command::new("libra") + .arg("fetch") + .arg("origin") + .arg(mr_link) + .output() + .await + .expect("Failed to execute libra fetch"); + // libra branch QB0X1X1K origin/QB0X1X1K + Command::new("libra") + .arg("branch") + .arg(mr_link) + .arg(format!("origin/{}", mr_link)) + .output() + .await + .expect("Failed to execute libra branch"); + // libra switch QB0X1X1K + Command::new("libra") + .arg("switch") + .arg(mr_link) + .output() + .await + .expect("Failed to execute libra switch"); + } else { + env::set_current_dir(&clone_path).unwrap(); } - Command::new("mkdir") - .arg(mr_link) - .output() - .await - .expect("Failed to mkdir"); - // cd QB0X1X1K - env::set_current_dir(&clone_path).unwrap(); - // libra init - Command::new("libra") - .arg("init") - .output() - .await - .expect("Failed to execute libra init"); - // libra remote add origin http://localhost:8000/project - Command::new("libra") - .arg("remote") - .arg("add") - .arg("origin") - .arg(format!("http://localhost:8000{}", mr.path)) - .output() - .await - .expect("Failed to execute libra remote add"); - // libra fetch origin QB0X1X1K - Command::new("libra") - .arg("fetch") - .arg("origin") - .arg(mr_link) - .output() - .await - .expect("Failed to execute libra fetch"); - // libra branch QB0X1X1K origin/QB0X1X1K - Command::new("libra") - .arg("branch") - .arg(mr_link) - .arg(format!("origin/{}", mr_link)) - .output() - .await - .expect("Failed to execute libra branch"); - // libra switch QB0X1X1K - Command::new("libra") - .arg("switch") - .arg(mr_link) - .output() - .await - .expect("Failed to execute libra switch"); - // libra diff --old 14899d8b9c36334a640c2e17255a546b0b9df105 + // libra diff --old hash let output = Command::new("libra") .arg("diff") .arg("--old") diff --git a/ceres/src/pack/import_repo.rs b/ceres/src/pack/import_repo.rs index 3868692bd..f675c9734 100644 --- a/ceres/src/pack/import_repo.rs +++ b/ceres/src/pack/import_repo.rs @@ -364,7 +364,7 @@ impl ImportRepo { let new_commit = Commit::from_tree_id( save_trees.back().unwrap().id, vec![SHA1::from_str(&root_ref.ref_commit_hash).unwrap()], - &commit_msg, + &format!("\n{}", commit_msg), ); let save_trees: Vec = save_trees diff --git a/jupiter/src/utils/converter.rs b/jupiter/src/utils/converter.rs index 61b9a68d6..d1277ea35 100644 --- a/jupiter/src/utils/converter.rs +++ b/jupiter/src/utils/converter.rs @@ -101,7 +101,7 @@ impl MegaModelConverter { pub fn init(mono_config: &MonoConfig) -> Self { let (tree_maps, blob_maps, root_tree) = init_trees(mono_config); - let commit = Commit::from_tree_id(root_tree.id, vec![], "Init Mega Directory"); + let commit = Commit::from_tree_id(root_tree.id, vec![], "\nInit Mega Directory"); let mega_ref = mega_refs::Model { id: generate_id(), @@ -156,7 +156,7 @@ mod test { let commit = Commit::from_tree_id( SHA1::from_str("bd4a28f2d8b2efc371f557c3b80d320466ed83f3").unwrap(), vec![], - "Init Mega Directory", + "\nInit Mega Directory", ); println!("{}", commit); } diff --git a/moon/package.json b/moon/package.json index e14b6c819..b299cc4a9 100644 --- a/moon/package.json +++ b/moon/package.json @@ -24,7 +24,7 @@ "github-markdown-css": "^5.8.1", "highlight.js": "^11.10.0", "lexical": "^0.21.0", - "next": "^15.0.3", + "next": "^15.0.4", "prism-react-renderer": "^2.4.0", "react": "^18.3.1", "react-dom": "^18.3.1", @@ -32,11 +32,11 @@ }, "devDependencies": { "@types/node": "^22.10.1", - "@types/react": "^18.3.13", - "@types/react-dom": "^18.3.0", + "@types/react": "18.3.13", + "@types/react-dom": "18.3.0", "autoprefixer": "^10.4.19", "eslint": "^9.16.0", - "eslint-config-next": "^15.0.3", + "eslint-config-next": "^15.0.4", "postcss": "^8.4.49", "typescript": "^5.6.3" } diff --git a/moon/src/app/(dashboard)/mr/[id]/page.tsx b/moon/src/app/(dashboard)/mr/[id]/page.tsx index f05e60ccc..5e3fb8178 100644 --- a/moon/src/app/(dashboard)/mr/[id]/page.tsx +++ b/moon/src/app/(dashboard)/mr/[id]/page.tsx @@ -68,13 +68,12 @@ export default function MRDetailPage({ params }: { params: Params }) { const detail = await fetch(`/api/mr/${id}/files-changed`); const res = await detail.json(); setOutputHtml(Diff2Html.html(res.data.data, { drawFileList: true, matching: 'lines' })); - }, []) + }, [id]) useEffect(() => { fetchDetail() fetchFileList(); checkLogin(); - get_diff_content() }, [id, fetchDetail, fetchFileList]); const set_to_loading = (index: number) => { @@ -164,6 +163,13 @@ export default function MRDetailPage({ params }: { params: Params }) { return element }); + const onTabsChange = (key: string) => { + console.log(key); + if (key === '2') { + get_diff_content() + } + }; + const tab_items: TabsProps['items'] = [ { key: '1', @@ -218,7 +224,7 @@ export default function MRDetailPage({ params }: { params: Params }) { Merge MR } - + ) }