Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
100 changes: 51 additions & 49 deletions ceres/src/api_service/mono_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion ceres/src/pack/import_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<mega_tree::ActiveModel> = save_trees
Expand Down
4 changes: 2 additions & 2 deletions jupiter/src/utils/converter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down Expand Up @@ -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);
}
Expand Down
8 changes: 4 additions & 4 deletions moon/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,19 @@
"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",
"react-markdown": "^9.0.1"
},
"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"
}
Expand Down
12 changes: 9 additions & 3 deletions moon/src/app/(dashboard)/mr/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -218,7 +224,7 @@ export default function MRDetailPage({ params }: { params: Params }) {
Merge MR
</Button>
}
<Tabs defaultActiveKey="1" items={tab_items} />
<Tabs defaultActiveKey="1" items={tab_items} onChange={onTabsChange} />
</Card>
)
}