Skip to content

Commit 794528b

Browse files
committed
feat(mono):intorduce bellatrix under orion-server for trigger build
1 parent 444c8c1 commit 794528b

40 files changed

Lines changed: 570 additions & 176 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ saturn = { path = "saturn" }
3636
mono = { path = "mono" }
3737
observatory = { path = "extensions/observatory" }
3838
orion = { path = "orion" }
39+
bellatrix = { path = "orion-server/bellatrix" }
3940
context = { path = "context" }
4041
neptune = { path = "neptune" }
4142

ceres/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jupiter = { workspace = true }
1616
callisto = { workspace = true }
1717
mercury = { workspace = true }
1818
neptune = { workspace = true }
19+
bellatrix = { workspace = true }
1920

2021
anyhow = { workspace = true }
2122
tokio = { workspace = true, features = ["net", "process"] }

ceres/src/api_service/mono_api_service.rs

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ use async_trait::async_trait;
4444
use callisto::sea_orm_active_enums::ConvTypeEnum;
4545
use callisto::{mega_blob, mega_mr, mega_tree, raw_blob};
4646
use common::errors::MegaError;
47-
use neptune::neptune_engine::Diff;
4847
use jupiter::storage::base_storage::StorageConnector;
4948
use jupiter::storage::Storage;
5049
use jupiter::utils::converter::generate_git_keep_with_timestamp;
@@ -53,6 +52,7 @@ use mercury::hash::SHA1;
5352
use mercury::internal::object::blob::Blob;
5453
use mercury::internal::object::commit::Commit;
5554
use mercury::internal::object::tree::{Tree, TreeItem, TreeItemMode};
55+
use neptune::neptune_engine::Diff;
5656

5757
use crate::api_service::ApiHandler;
5858
use crate::model::git::CreateFileInfo;
@@ -378,22 +378,21 @@ impl MonoApiService {
378378
///
379379
/// # Returns
380380
/// String containing the unified diff output
381-
pub async fn content_diff(
382-
&self,
383-
mr_link: &str,
384-
) -> Result<String, GitError> {
381+
pub async fn content_diff(&self, mr_link: &str) -> Result<String, GitError> {
385382
let stg = self.storage.mr_storage();
386-
let mr = stg.get_mr(mr_link).await.unwrap().ok_or_else(|| {
387-
GitError::CustomError(format!("Merge request not found: {mr_link}"))
388-
})?;
389-
390-
let old_blobs = self.get_commit_blobs(&mr.from_hash).await.map_err(|e| {
391-
GitError::CustomError(format!("Failed to get old commit blobs: {e}"))
392-
})?;
393-
let new_blobs = self.get_commit_blobs(&mr.to_hash).await.map_err(|e| {
394-
GitError::CustomError(format!("Failed to get new commit blobs: {e}"))
395-
})?;
383+
let mr =
384+
stg.get_mr(mr_link).await.unwrap().ok_or_else(|| {
385+
GitError::CustomError(format!("Merge request not found: {mr_link}"))
386+
})?;
396387

388+
let old_blobs = self
389+
.get_commit_blobs(&mr.from_hash)
390+
.await
391+
.map_err(|e| GitError::CustomError(format!("Failed to get old commit blobs: {e}")))?;
392+
let new_blobs = self
393+
.get_commit_blobs(&mr.to_hash)
394+
.await
395+
.map_err(|e| GitError::CustomError(format!("Failed to get new commit blobs: {e}")))?;
397396

398397
let algo = "histogram".to_string(); // Default diff algorithm
399398
let filter_paths: Vec<PathBuf> = Vec::new(); // No filtering by default
@@ -428,13 +427,7 @@ impl MonoApiService {
428427
};
429428

430429
// Use the unified diff function that returns a single string
431-
let diff_output = Diff::diff(
432-
old_blobs,
433-
new_blobs,
434-
algo,
435-
filter_paths,
436-
read_content,
437-
).await;
430+
let diff_output = Diff::diff(old_blobs, new_blobs, algo, filter_paths, read_content).await;
438431

439432
Ok(diff_output)
440433
}

ceres/src/model/mr.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@ pub enum MrDiffFile {
1010
// path, old_hash, new_hash
1111
Modified(PathBuf, SHA1, SHA1),
1212
}
13+
14+
#[derive(Serialize)]
15+
pub struct BuckFile {
16+
pub buck: SHA1,
17+
pub buck_config: SHA1,
18+
pub path: PathBuf,
19+
}

ceres/src/pack/import_repo.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use mercury::{hash::SHA1, internal::pack::encode::PackEncoder};
2424

2525
use crate::{
2626
api_service::{mono_api_service::MonoApiService, ApiHandler},
27-
pack::PackHandler,
27+
pack::RepoHandler,
2828
protocol::{
2929
import_refs::{CommandType, RefCommand, Refs},
3030
repo::Repo,
@@ -38,7 +38,7 @@ pub struct ImportRepo {
3838
}
3939

4040
#[async_trait]
41-
impl PackHandler for ImportRepo {
41+
impl RepoHandler for ImportRepo {
4242
async fn head_hash(&self) -> (String, Vec<Refs>) {
4343
let result = self
4444
.storage
@@ -292,6 +292,14 @@ impl PackHandler for ImportRepo {
292292
Ok(())
293293
}
294294

295+
async fn save_or_update_mr(&self) -> Result<(), MegaError> {
296+
Ok(())
297+
}
298+
299+
async fn post_mr_operation(&self) -> Result<(), MegaError> {
300+
Ok(())
301+
}
302+
295303
async fn check_commit_exist(&self, hash: &str) -> bool {
296304
self.storage
297305
.git_db_storage()

ceres/src/pack/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub mod import_repo;
3737
pub mod monorepo;
3838

3939
#[async_trait]
40-
pub trait PackHandler: Send + Sync + 'static {
40+
pub trait RepoHandler: Send + Sync + 'static {
4141
async fn head_hash(&self) -> (String, Vec<Refs>);
4242

4343
async fn receiver_handler(
@@ -116,6 +116,10 @@ pub trait PackHandler: Send + Sync + 'static {
116116

117117
async fn update_refs(&self, refs: &RefCommand) -> Result<(), GitError>;
118118

119+
async fn save_or_update_mr(&self) -> Result<(), MegaError>;
120+
121+
async fn post_mr_operation(&self) -> Result<(), MegaError>;
122+
119123
async fn check_commit_exist(&self, hash: &str) -> bool;
120124

121125
async fn check_default_branch(&self) -> bool;

0 commit comments

Comments
 (0)