Skip to content

Commit 6395cd6

Browse files
authored
Merge pull request #793 from benjamin-747/main
fix some issue when testing openeuler repos
2 parents b9fd775 + 5a8c441 commit 6395cd6

File tree

18 files changed

+120
-86
lines changed

18 files changed

+120
-86
lines changed

Cargo.toml

+10-9
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ members = [
1515
"taurus",
1616
"lunar/src-tauri",
1717
"atlas",
18-
"orion",
19-
"panel",
18+
# "orion",
19+
# "panel",
2020
]
2121
default-members = ["mega", "mono", "libra", "aries"]
2222
resolver = "1"
@@ -43,7 +43,7 @@ serde_json = "1.0.132"
4343
tracing = "0.1.40"
4444
tracing-subscriber = "0.3.19"
4545
tracing-appender = "0.2"
46-
thiserror = "2.0.6"
46+
thiserror = "2.0.9"
4747
rand = "0.8.5"
4848
smallvec = "1.13.2"
4949
tokio = "1.42"
@@ -61,21 +61,21 @@ futures-util = "0.3.30"
6161
go-defer = "0.1.0"
6262
russh = "0.49.0"
6363
russh-keys = "0.49.1"
64-
axum = "0.7.7"
65-
axum-extra = "0.9.4"
64+
axum = "0.8.1"
65+
axum-extra = "0.10.0"
6666
axum-server = "0.7.1"
6767
tower-http = "0.6.1"
68-
tower = "0.5.1"
68+
tower = "0.5.2"
6969
hex = "0.4.3"
70-
sea-orm = "1.1.1"
70+
sea-orm = "1.1.3"
7171
flate2 = "1.0.35"
7272
bstr = "1.11.0"
7373
colored = "2.1.0"
7474
idgenerator = "2.0.0"
7575
num_cpus = "1.16.0"
76-
config = "0.15.0"
76+
config = "0.15.4"
7777
shadow-rs = "0.36.0"
78-
reqwest = "0.12.9"
78+
reqwest = "0.12.12"
7979
lazy_static = "1.5.0"
8080
uuid = "1.11.0"
8181
regex = "1.11.1"
@@ -89,6 +89,7 @@ cedar-policy = "4.2.2"
8989
secp256k1 = "0.30.0"
9090
oauth2 = "4.4.2"
9191
base64 = "0.22.1"
92+
encoding_rs = "0.8.31"
9293

9394
[profile.release]
9495
debug = true

ceres/src/api_service/import_api_service.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use std::collections::VecDeque;
44
use std::path::Path;
55
use std::path::PathBuf;
66

7-
use axum::async_trait;
7+
use async_trait::async_trait;
88

99
use jupiter::context::Context;
1010
use mercury::errors::GitError;

ceres/src/api_service/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::{
33
path::{Component, Path, PathBuf},
44
};
55

6-
use axum::async_trait;
6+
use async_trait::async_trait;
77

88
use callisto::raw_blob;
99
use common::errors::MegaError;

ceres/src/api_service/mono_api_service.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use std::path::{Path, PathBuf};
33
use std::str::FromStr;
44
use std::{env, fs};
55

6-
use axum::async_trait;
6+
use async_trait::async_trait;
77
use tokio::process::Command;
88

99
use callisto::db_enums::ConvType;

gateway/src/https_server.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,20 @@ pub async fn app(
154154
// add TraceLayer for log record
155155
// add CorsLayer to add cors header
156156
Router::new()
157-
.nest(
158-
"/",
159-
lfs_router::routers().with_state(mono_api_state.clone()),
160-
)
161-
.nest(
162-
"/api/v1/mono",
163-
mono::api::api_router::routers().with_state(mono_api_state.clone()),
164-
)
165-
.nest(
166-
"/api/v1/mega",
167-
mega_routers().with_state(mega_api_state.clone()),
157+
.merge(lfs_router::routers().with_state(mono_api_state.clone()))
158+
.merge(
159+
Router::new()
160+
.nest(
161+
"/api/v1/mono",
162+
mono::api::api_router::routers().with_state(mono_api_state.clone()),
163+
)
164+
.nest(
165+
"/api/v1/mega",
166+
mega_routers().with_state(mega_api_state.clone()),
167+
),
168168
)
169169
// Using Regular Expressions for Path Matching in Protocol
170-
.route("/*path", get(get_method_router).post(post_method_router))
170+
.route("/{*path}", get(get_method_router).post(post_method_router))
171171
.layer(
172172
ServiceBuilder::new().layer(CorsLayer::new().allow_origin(Any).allow_headers(vec![
173173
http::header::AUTHORIZATION,

gemini/Cargo.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ reqwest = { workspace = true }
2525
tracing = { workspace = true }
2626
tokio = { workspace = true, features = ["net"] }
2727
chrono = { workspace = true }
28-
secp256k1 = { workspace = true , features = ["serde", "rand","hashes"] }
28+
secp256k1 = { workspace = true, features = ["serde", "rand", "hashes"] }
2929
ring = "0.17.8"
30-
hex = { workspace = true }
30+
hex = { workspace = true }
31+
async-trait = { workspace = true }

gemini/src/ztm/agent.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{
55
time::Duration,
66
};
77

8-
use axum::async_trait;
8+
use async_trait::async_trait;
99
use common::config::Config;
1010
use reqwest::{header::CONTENT_TYPE, Client};
1111
use serde::{Deserialize, Serialize};

gemini/src/ztm/hub.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use ::serde::{Deserialize, Serialize};
2-
use axum::async_trait;
2+
use async_trait::async_trait;
33
use reqwest::Client;
44
use serde_json::Value;
55

mercury/Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ futures-util = { workspace = true }
3434
bytes = { workspace = true }
3535
axum = { workspace = true }
3636
memchr = { workspace = true }
37+
encoding_rs = { workspace = true }
3738
rayon = "1.10.0"
3839

3940
[target.'cfg(windows)'.dependencies] # only on Windows

mercury/src/internal/object/tree.rs

+23-10
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@
1414
//! have been added, modified, or deleted between two points in time. This allows Git to perform
1515
//! operations like merging and rebasing more quickly and accurately.
1616
//!
17-
use std::fmt::Display;
18-
use colored::Colorize;
19-
use serde::Deserialize;
20-
use serde::Serialize;
2117
use crate::errors::GitError;
2218
use crate::hash::SHA1;
2319
use crate::internal::object::ObjectTrait;
2420
use crate::internal::object::ObjectType;
25-
21+
use colored::Colorize;
22+
use encoding_rs::GBK;
23+
use serde::Deserialize;
24+
use serde::Serialize;
25+
use std::fmt::Display;
2626

2727
/// In Git, the mode field in a tree object's entry specifies the type of the object represented by
2828
/// that entry. The mode is a three-digit octal number that encodes both the permissions and the
@@ -180,13 +180,26 @@ impl TreeItem {
180180
let mode = parts.next().unwrap();
181181
let rest = parts.next().unwrap();
182182
let mut parts = rest.splitn(2, |b| *b == b'\0');
183-
let name = parts.next().unwrap();
183+
let raw_name = parts.next().unwrap();
184184
let id = parts.next().unwrap();
185185

186+
let name = if String::from_utf8(raw_name.to_vec()).is_ok() {
187+
String::from_utf8(raw_name.to_vec()).unwrap()
188+
} else {
189+
let (decoded, _, had_errors) = GBK.decode(raw_name);
190+
if had_errors {
191+
return Err(GitError::InvalidTreeItem(format!(
192+
"Unsupported raw format: {:?}",
193+
raw_name
194+
)));
195+
} else {
196+
decoded.to_string()
197+
}
198+
};
186199
Ok(TreeItem {
187200
mode: TreeItemMode::tree_item_type_from_bytes(mode)?,
188201
id: SHA1::from_bytes(id),
189-
name: String::from_utf8(name.to_vec())?,
202+
name,
190203
})
191204
}
192205

@@ -262,7 +275,7 @@ impl Tree {
262275
}
263276

264277
/// After the subdirectory is changed, the hash value of the tree is recalculated.
265-
pub fn rehash(&mut self){
278+
pub fn rehash(&mut self) {
266279
let mut data = Vec::new();
267280
for item in &self.tree_items {
268281
data.extend_from_slice(item.to_data().as_slice());
@@ -271,9 +284,9 @@ impl Tree {
271284
}
272285
}
273286

274-
impl TryFrom<&[u8]> for Tree{
287+
impl TryFrom<&[u8]> for Tree {
275288
type Error = GitError;
276-
fn try_from(data: &[u8]) -> Result<Self, Self::Error> {
289+
fn try_from(data: &[u8]) -> Result<Self, Self::Error> {
277290
let h = SHA1::from_type_and_data(ObjectType::Tree, data);
278291
Tree::from_bytes(data, h)
279292
}

mono/src/api/api_router.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub fn routers() -> Router<MonoApiServiceState> {
3535
.route("/tree/path-can-clone", get(path_can_be_cloned))
3636
.route("/tree", get(get_tree_info))
3737
.route("/blob", get(get_blob_string))
38-
.route("/file/blob/:object_id", get(get_blob_file))
38+
.route("/file/blob/{object_id}", get(get_blob_file))
3939
.route("/file/tree", get(get_tree_file));
4040
Router::new()
4141
.merge(router)

mono/src/api/issue/issue_router.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ use crate::api::oauth::model::LoginUser;
1414
use crate::api::MonoApiServiceState;
1515

1616
pub fn routers() -> Router<MonoApiServiceState> {
17-
Router::new()
18-
.route("/issue/list", post(fetch_issue_list))
19-
.route("/issue/new", post(new_issue))
20-
.route("/issue/:link/close", post(close_issue))
21-
.route("/issue/:link/reopen", post(reopen_issue))
22-
.route("/issue/:link/detail", get(issue_detail))
23-
.route("/issue/:link/comment", post(save_comment))
24-
.route("/issue/comment/:id/delete", post(delete_comment))
17+
Router::new().nest(
18+
"/issue",
19+
Router::new()
20+
.route("/list", post(fetch_issue_list))
21+
.route("/new", post(new_issue))
22+
.route("/{link}/close", post(close_issue))
23+
.route("/{link}/reopen", post(reopen_issue))
24+
.route("/{link}/detail", get(issue_detail))
25+
.route("/{link}/comment", post(save_comment))
26+
.route("/comment/{id}/delete", post(delete_comment)),
27+
)
2528
}
2629

2730
#[derive(Deserialize)]

mono/src/api/lfs/lfs_router.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,15 @@ const LFS_CONTENT_TYPE: &str = "application/vnd.git-lfs+json";
7070
/// document describes the server LFS discovery protocol.
7171
pub fn routers() -> Router<MonoApiServiceState> {
7272
Router::new()
73-
.route("/objects/:object_id", get(lfs_download_object))
74-
.route("/objects/:object_id/:chunk_id", get(lfs_download_chunk))
75-
.route("/objects/:object_id", put(lfs_upload_object))
73+
.route("/objects/{object_id}", get(lfs_download_object))
74+
.route("/objects/{object_id}/{chunk_id}", get(lfs_download_chunk))
75+
.route("/objects/{object_id}", put(lfs_upload_object))
7676
.route("/locks", get(list_locks))
7777
.route("/locks", post(create_lock))
7878
.route("/locks/verify", post(list_locks_for_verification))
79-
.route("/locks/:id/unlock", post(delete_lock))
79+
.route("/locks/{id}/unlock", post(delete_lock))
8080
.route("/objects/batch", post(lfs_process_batch))
81-
.route("/objects/:object_id/chunks", get(lfs_fetch_chunk_ids))
81+
.route("/objects/{object_id}/chunks", get(lfs_fetch_chunk_ids))
8282
}
8383

8484
pub async fn list_locks(
@@ -103,7 +103,8 @@ pub async fn list_locks_for_verification(
103103
state: State<MonoApiServiceState>,
104104
Json(json): Json<VerifiableLockRequest>,
105105
) -> Result<Response<Body>, (StatusCode, String)> {
106-
let result = handler::lfs_verify_lock(state.context.services.lfs_db_storage.clone(), json).await;
106+
let result =
107+
handler::lfs_verify_lock(state.context.services.lfs_db_storage.clone(), json).await;
107108
match result {
108109
Ok(lock_list) => {
109110
let body = serde_json::to_string(&lock_list).unwrap_or_default();
@@ -125,7 +126,8 @@ pub async fn create_lock(
125126
state: State<MonoApiServiceState>,
126127
Json(json): Json<LockRequest>,
127128
) -> Result<Response<Body>, (StatusCode, String)> {
128-
let result = handler::lfs_create_lock(state.context.services.lfs_db_storage.clone(), json).await;
129+
let result =
130+
handler::lfs_create_lock(state.context.services.lfs_db_storage.clone(), json).await;
129131
match result {
130132
Ok(lock) => {
131133
let lock_response = LockResponse {

mono/src/api/mr/mr_router.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,18 @@ use crate::api::util;
2121
use crate::api::MonoApiServiceState;
2222

2323
pub fn routers() -> Router<MonoApiServiceState> {
24-
Router::new()
25-
.route("/mr/list", post(fetch_mr_list))
26-
.route("/mr/:link/detail", get(mr_detail))
27-
.route("/mr/:link/merge", post(merge))
28-
.route("/mr/:link/close", post(close_mr))
29-
.route("/mr/:link/reopen", post(reopen_mr))
30-
.route("/mr/:link/files-changed", get(get_mr_files_changed))
31-
.route("/mr/:link/comment", post(save_comment))
32-
.route("/mr/comment/:conv_id/delete", post(delete_comment))
24+
Router::new().nest(
25+
"/mr",
26+
Router::new()
27+
.route("/list", post(fetch_mr_list))
28+
.route("/{link}/detail", get(mr_detail))
29+
.route("/{link}/merge", post(merge))
30+
.route("/{link}/close", post(close_mr))
31+
.route("/{link}/reopen", post(reopen_mr))
32+
.route("/{link}/files-changed", get(get_mr_files_changed))
33+
.route("/{link}/comment", post(save_comment))
34+
.route("/comment/{conv_id}/delete", post(delete_comment)),
35+
)
3336
}
3437

3538
async fn reopen_mr(

mono/src/api/oauth/mod.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use anyhow::Context;
22
use async_session::{MemoryStore, Session, SessionStore};
33
use axum::{
4-
async_trait,
54
extract::{FromRef, FromRequestParts, Query, State},
65
http::{header::SET_COOKIE, HeaderMap},
76
response::{IntoResponse, Redirect, Response},
@@ -79,7 +78,8 @@ async fn login_authorized(
7978
}
8079

8180
let new_user: user::Model = github_user.into();
82-
let user = state.user_stg()
81+
let user = state
82+
.user_stg()
8383
.find_user_by_email(&new_user.email)
8484
.await
8585
.unwrap();
@@ -190,7 +190,6 @@ impl IntoResponse for AuthRedirect {
190190
}
191191
}
192192

193-
#[async_trait]
194193
impl<S> FromRequestParts<S> for LoginUser
195194
where
196195
MemoryStore: FromRef<S>,

mono/src/api/user/user_router.rs

+18-10
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,18 @@ use crate::api::MonoApiServiceState;
1616
use crate::api::{error::ApiError, oauth::model::LoginUser, util};
1717

1818
pub fn routers() -> Router<MonoApiServiceState> {
19-
Router::new()
20-
.route("/user", get(user))
21-
.route("/user/ssh", get(list_key))
22-
.route("/user/ssh", post(add_key))
23-
.route("/user/ssh/:key_id/delete", post(remove_key))
24-
.route("/user/token/generate", post(generate_token))
25-
.route("/user/token/list", get(list_token))
26-
.route("/user/token/:key_id/delete", post(remove_token))
27-
.route("/repo-permissions", get(repo_permissions))
19+
Router::new().nest(
20+
"/user",
21+
Router::new()
22+
.route("/", get(user))
23+
.route("/ssh", get(list_key))
24+
.route("/ssh", post(add_key))
25+
.route("/ssh/{key_id}/delete", post(remove_key))
26+
.route("/token/generate", post(generate_token))
27+
.route("/token/list", get(list_token))
28+
.route("/token/{key_id}/delete", post(remove_token))
29+
.route("/repo-permissions", get(repo_permissions)),
30+
)
2831
}
2932

3033
async fn user(
@@ -54,7 +57,12 @@ async fn add_key(
5457

5558
let res = state
5659
.user_stg()
57-
.save_ssh_key(user.user_id, &title, &json.ssh_key, &key.fingerprint(HashAlg::Sha256).to_string())
60+
.save_ssh_key(
61+
user.user_id,
62+
&title,
63+
&json.ssh_key,
64+
&key.fingerprint(HashAlg::Sha256).to_string(),
65+
)
5866
.await;
5967
let res = match res {
6068
Ok(_) => CommonResult::success(None),

0 commit comments

Comments
 (0)