Skip to content

Commit ceae72a

Browse files
authored
fix(UI):use username in conversation and fix clippy in 1.88 (#1171)
* fix(UI):use username in conversation * fix clippy
1 parent 48ae58d commit ceae72a

File tree

132 files changed

+558
-513
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

132 files changed

+558
-513
lines changed

ceres/src/api_service/mono_api_service.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ impl ApiHandler for MonoApiService {
232232
}
233233

234234
impl MonoApiService {
235-
pub async fn merge_mr(&self, user_id: String, mr: mega_mr::Model) -> Result<(), MegaError> {
235+
pub async fn merge_mr(&self, username: &str, mr: mega_mr::Model) -> Result<(), MegaError> {
236236
let storage = self.storage.services.mono_storage.clone();
237237
let refs = storage.get_ref(&mr.path).await.unwrap().unwrap();
238238

@@ -261,7 +261,7 @@ impl MonoApiService {
261261
// add conversation
262262
self.storage
263263
.issue_storage()
264-
.add_conversation(&mr.link, &user_id, None, ConvTypeEnum::Merged)
264+
.add_conversation(&mr.link, username, None, ConvTypeEnum::Merged)
265265
.await
266266
.unwrap();
267267
// update mr status last
@@ -434,7 +434,7 @@ mod test {
434434
let cloned_path = full_path.clone(); // Clone full_path
435435
let name = cloned_path.file_name().unwrap().to_str().unwrap();
436436
full_path.pop();
437-
println!("name: {}, path: {:?}", name, full_path);
437+
println!("name: {name}, path: {full_path:?}");
438438
}
439439
}
440440
}

ceres/src/pack/import_repo.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ impl PackHandler for ImportRepo {
122122
let entry = c.into();
123123
entry_tx.send(entry).await.unwrap();
124124
}
125-
Err(err) => eprintln!("Error: {:?}", err),
125+
Err(err) => eprintln!("Error: {err:?}"),
126126
}
127127
}
128128
tracing::info!("send commits end");
@@ -135,7 +135,7 @@ impl PackHandler for ImportRepo {
135135
let entry = t.into();
136136
entry_tx.send(entry).await.unwrap();
137137
}
138-
Err(err) => eprintln!("Error: {:?}", err),
138+
Err(err) => eprintln!("Error: {err:?}"),
139139
}
140140
}
141141
tracing::info!("send trees end");
@@ -145,7 +145,7 @@ impl PackHandler for ImportRepo {
145145
while let Some(model) = bid_stream.next().await {
146146
match model {
147147
Ok(m) => bids.push(m.blob_id),
148-
Err(err) => eprintln!("Error: {:?}", err),
148+
Err(err) => eprintln!("Error: {err:?}"),
149149
}
150150
}
151151

@@ -164,7 +164,7 @@ impl PackHandler for ImportRepo {
164164
let entry: Entry = b.into();
165165
sender_clone.send(entry).await.unwrap();
166166
}
167-
Err(err) => eprintln!("Error: {:?}", err),
167+
Err(err) => eprintln!("Error: {err:?}"),
168168
}
169169
}
170170
// });
@@ -383,7 +383,7 @@ impl ImportRepo {
383383
let new_commit = Commit::from_tree_id(
384384
save_trees.back().unwrap().id,
385385
vec![SHA1::from_str(&root_ref.ref_commit_hash).unwrap()],
386-
&format!("\n{}", commit_msg),
386+
&format!("\n{commit_msg}"),
387387
);
388388

389389
let save_trees: Vec<mega_tree::ActiveModel> = save_trees
@@ -415,7 +415,7 @@ mod test {
415415
let path = PathBuf::from("/third-party/crates/tokio/tokio-console");
416416
let ancestors: Vec<_> = path.ancestors().collect();
417417
for path in ancestors.into_iter() {
418-
println!("{:?}", path);
418+
println!("{path:?}");
419419
}
420420
}
421421
}

ceres/src/protocol/smart.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,10 +70,10 @@ impl SmartProtocol {
7070
"HEAD"
7171
};
7272
let cap_list = match service_type {
73-
ServiceType::UploadPack => format!("{}{}", UPLOAD_CAP_LIST, COMMON_CAP_LIST),
74-
ServiceType::ReceivePack => format!("{}{}", RECEIVE_CAP_LIST, COMMON_CAP_LIST),
73+
ServiceType::UploadPack => format!("{UPLOAD_CAP_LIST}{COMMON_CAP_LIST}"),
74+
ServiceType::ReceivePack => format!("{RECEIVE_CAP_LIST}{COMMON_CAP_LIST}"),
7575
};
76-
let pkt_line = format!("{}{}{}{}{}{}", head_hash, SP, name, NUL, cap_list, LF);
76+
let pkt_line = format!("{head_hash}{SP}{name}{NUL}{cap_list}{LF}");
7777
let mut ref_list = vec![pkt_line];
7878

7979
for git_ref in git_refs {
@@ -152,7 +152,7 @@ impl SmartProtocol {
152152

153153
for hash in &have {
154154
if pack_handler.check_commit_exist(hash).await {
155-
add_pkt_line_string(&mut protocol_buf, format!("ACK {} common\n", hash));
155+
add_pkt_line_string(&mut protocol_buf, format!("ACK {hash} common\n"));
156156
if last_common_commit.is_empty() {
157157
last_common_commit = hash.to_string();
158158
}
@@ -174,7 +174,7 @@ impl SmartProtocol {
174174
if self.capabilities.contains(&Capability::NoDone) {
175175
// If multi_ack_detailed and no-done are both present, then the sender is free to immediately send a pack
176176
// following its first "ACK obj-id ready" message.
177-
add_pkt_line_string(&mut protocol_buf, format!("ACK {} ready\n", hash));
177+
add_pkt_line_string(&mut protocol_buf, format!("ACK {hash} ready\n"));
178178
}
179179
}
180180
} else {
@@ -183,7 +183,7 @@ impl SmartProtocol {
183183
let (_, rx) = tokio::sync::mpsc::channel::<Vec<u8>>(1);
184184
pack_data = ReceiverStream::new(rx);
185185
}
186-
add_pkt_line_string(&mut protocol_buf, format!("ACK {} \n", last_common_commit));
186+
add_pkt_line_string(&mut protocol_buf, format!("ACK {last_common_commit} \n"));
187187
}
188188
Ok((pack_data, protocol_buf))
189189
}
@@ -299,7 +299,7 @@ impl SmartProtocol {
299299
pub fn build_smart_reply(&self, ref_list: &Vec<String>, service: String) -> BytesMut {
300300
let mut pkt_line_stream = BytesMut::new();
301301
if self.transport_protocol == TransportProtocol::Http {
302-
add_pkt_line_string(&mut pkt_line_stream, format!("# service={}\n", service));
302+
add_pkt_line_string(&mut pkt_line_stream, format!("# service={service}\n"));
303303
pkt_line_stream.put(&PKT_LINE_END_MARKER[..]);
304304
}
305305

@@ -385,7 +385,7 @@ pub fn read_pkt_line(bytes: &mut Bytes) -> (usize, Bytes) {
385385
}
386386
let pkt_length = bytes.copy_to_bytes(4);
387387
let pkt_length = usize::from_str_radix(core::str::from_utf8(&pkt_length).unwrap(), 16)
388-
.unwrap_or_else(|_| panic!("{:?} is not a valid digit?", pkt_length));
388+
.unwrap_or_else(|_| panic!("{pkt_length:?} is not a valid digit?"));
389389
if pkt_length == 0 {
390390
return (0, Bytes::new());
391391
}

common/src/config.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl Default for Config {
171171
.lines()
172172
.map(|line| {
173173
if line.starts_with("base_dir ") {
174-
format!("base_dir = {:?}", base_dir)
174+
format!("base_dir = {base_dir:?}")
175175
} else {
176176
line.to_string()
177177
}
@@ -257,7 +257,7 @@ fn traverse_config(key: &str, value: &c::Value, f: &impl Fn(&str, &c::Value)) {
257257
let new_key = if key.is_empty() {
258258
k.clone()
259259
} else {
260-
format!("{}.{}", key, k)
260+
format!("{key}.{k}")
261261
};
262262
traverse_config(&new_key, v, f);
263263
}
@@ -424,7 +424,7 @@ impl PackConfig {
424424
let percentage: f64 = size_str
425425
.trim_end_matches('%')
426426
.parse()
427-
.map_err(|_| format!("Invalid percentage: {}", size_str))?;
427+
.map_err(|_| format!("Invalid percentage: {size_str}"))?;
428428
let total_mem = fn_get_total_capacity()?;
429429

430430
return Ok((total_mem as f64 * percentage / 100.0) as usize);
@@ -457,7 +457,7 @@ impl PackConfig {
457457

458458
let value: f64 = number
459459
.parse()
460-
.map_err(|_| format!("Invalid size: {}", size_str))?;
460+
.map_err(|_| format!("Invalid size: {size_str}"))?;
461461
let unit = chars.collect::<String>().to_uppercase();
462462

463463
// For compatibility,
@@ -476,7 +476,7 @@ impl PackConfig {
476476
"MIB" | "M" => value * 1_024.0 * 1_024.0,
477477
"GIB" | "G" => value * 1_024.0 * 1_024.0 * 1_024.0,
478478
"TIB" | "T" => value * 1_099_511_627_776.0,
479-
_ => Err(format!("Invalid unit: {}", unit))?,
479+
_ => Err(format!("Invalid unit: {unit}"))?,
480480
};
481481

482482
Ok(bytes as usize)

common/src/enums.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ impl FromStr for SupportOauthType {
2121
fn from_str(s: &str) -> Result<Self, Self::Err> {
2222
match s {
2323
"github" => Ok(Self::GitHub),
24-
_ => Err(format!("'{}' is not a valid oauth type", s)),
24+
_ => Err(format!("'{s}' is not a valid oauth type")),
2525
}
2626
}
2727
}

common/src/utils.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn generate_rich_text(content: &str) -> String {
4444
}
4545

4646
pub fn mr_ref_name(mr_link: &str) -> String {
47-
format!("refs/mr/{}", mr_link)
47+
format!("refs/mr/{mr_link}")
4848
}
4949

5050
/// Format commit message with GPG signature<br>
@@ -54,10 +54,10 @@ pub fn mr_ref_name(mr_link: &str) -> String {
5454
pub fn format_commit_msg(msg: &str, gpg_sig: Option<&str>) -> String {
5555
match gpg_sig {
5656
None => {
57-
format!("\n{}", msg)
57+
format!("\n{msg}")
5858
}
5959
Some(gpg) => {
60-
format!("{}\n\n{}", gpg, msg)
60+
format!("{gpg}\n\n{msg}")
6161
}
6262
}
6363
}
@@ -96,8 +96,7 @@ pub fn check_conventional_commits_message(msg: &str) -> bool {
9696
let unicode_pattern = r"\p{L}\p{N}\p{P}\p{S}\p{Z}";
9797
// type only support characters&numbers, others fields support all unicode characters
9898
let regex_str = format!(
99-
r"^(?P<type>[\p{{L}}\p{{N}}_-]+)(?:\((?P<scope>[{unicode}]+)\))?!?: (?P<description>[{unicode}]+)$",
100-
unicode = unicode_pattern
99+
r"^(?P<type>[\p{{L}}\p{{N}}_-]+)(?:\((?P<scope>[{unicode_pattern}]+)\))?!?: (?P<description>[{unicode_pattern}]+)$",
101100
);
102101

103102
let re = Regex::new(&regex_str).unwrap();
@@ -116,7 +115,7 @@ pub fn check_conventional_commits_message(msg: &str) -> bool {
116115

117116
let commit_type = commit_type.unwrap();
118117
if !RECOMMENDED_TYPES.contains(&commit_type.to_lowercase().as_str()) {
119-
println!("`{}` is not a recommended commit type, refer to https://www.conventionalcommits.org/en/v1.0.0/ for more information", commit_type);
118+
println!("`{commit_type}` is not a recommended commit type, refer to https://www.conventionalcommits.org/en/v1.0.0/ for more information");
120119
}
121120

122121
// println!("{}({}): {}\n{}", commit_type, scope.unwrap_or("None".to_string()), description.unwrap(), body_footer);

gateway/src/api/github_router.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ async fn webhook(
3232
/// GitHub API: Get the files change of a pull request. <br>
3333
/// For read-only operation of public repos, no authentication is required.
3434
pub async fn get_pr_files(pr_url: &str) -> Value {
35-
get_request(&format!("{}/files", pr_url)).await
35+
get_request(&format!("{pr_url}/files")).await
3636
}
3737

3838
/// GitHub API: Get the commits of a pull request.
3939
pub async fn get_pr_commits(pr_url: &str) -> Value {
40-
get_request(&format!("{}/commits", pr_url)).await
40+
get_request(&format!("{pr_url}/commits")).await
4141
}
4242
/// Send a GET request to the given URL and return the JSON response.
4343
async fn get_request(url: &str) -> Value {

gateway/src/https_server.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub async fn http_server(context: AppContext, options: HttpOptions) {
4242

4343
let app = app(context.storage, host.clone(), port, p2p.clone()).await;
4444

45-
let server_url = format!("{}:{}", host, port);
45+
let server_url = format!("{host}:{port}");
4646

4747
let listener = tokio::net::TcpListener::bind(server_url).await.unwrap();
4848
axum::serve(listener, app.into_make_service())
@@ -61,7 +61,7 @@ pub async fn app(storage: Storage, host: String, port: u16, p2p: P2pOptions) ->
6161
storage: storage.clone(),
6262
oauth_client: None,
6363
store: None,
64-
listen_addr: format!("http://{}:{}", host, port),
64+
listen_addr: format!("http://{host}:{port}"),
6565
};
6666

6767
let mega_api_state = MegaApiServiceState {

gemini/src/ca/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ fn _is_reserved_key(name: String) -> bool {
9090
}
9191

9292
fn add_user_key_pre(name: String) -> String {
93-
format!("{}{}", USER_KEY_PRE, name)
93+
format!("{USER_KEY_PRE}{name}")
9494
}
9595

9696
pub fn get_cert_name_from_path(path: &str) -> Option<String> {

gemini/src/lfs/mod.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub async fn share_lfs(
4545
let json = serde_json::to_string(&lfs).unwrap();
4646

4747
let client = Client::new();
48-
let url = format!("{}/api/v1/lfs_share", bootstrap_node);
48+
let url = format!("{bootstrap_node}/api/v1/lfs_share");
4949
let response = client
5050
.post(url)
5151
.header("content-type", "application/json")
@@ -79,21 +79,20 @@ pub async fn share_lfs(
7979
///
8080
pub async fn get_lfs_chunks_info(bootstrap_node: String, file_hash: String) -> Option<LFSInfoRes> {
8181
let url = format!(
82-
"{}/api/v1/lfs_chunk?file_hash={}",
83-
bootstrap_node, file_hash
82+
"{bootstrap_node}/api/v1/lfs_chunk?file_hash={file_hash}"
8483
);
8584
let lfs_info: LFSInfoRes = match get(url.clone()).await {
8685
Ok(response) => {
8786
if !response.status().is_success() {
88-
println!("Get lfs chuncks info failed {}", url);
87+
println!("Get lfs chuncks info failed {url}");
8988
return None;
9089
}
9190
let body = response.text().await.unwrap();
9291
let lfs_info: LFSInfoRes = serde_json::from_str(&body).unwrap();
9392
lfs_info
9493
}
9594
Err(_) => {
96-
println!("Get lfs chuncks info failed {}", url);
95+
println!("Get lfs chuncks info failed {url}");
9796
return None;
9897
}
9998
};

0 commit comments

Comments
 (0)