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
6 changes: 3 additions & 3 deletions ceres/src/api_service/mono_api_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl ApiHandler for MonoApiService {
}

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

Expand Down Expand Up @@ -261,7 +261,7 @@ impl MonoApiService {
// add conversation
self.storage
.issue_storage()
.add_conversation(&mr.link, &user_id, None, ConvTypeEnum::Merged)
.add_conversation(&mr.link, username, None, ConvTypeEnum::Merged)
.await
.unwrap();
// update mr status last
Expand Down Expand Up @@ -434,7 +434,7 @@ mod test {
let cloned_path = full_path.clone(); // Clone full_path
let name = cloned_path.file_name().unwrap().to_str().unwrap();
full_path.pop();
println!("name: {}, path: {:?}", name, full_path);
println!("name: {name}, path: {full_path:?}");
}
}
}
12 changes: 6 additions & 6 deletions ceres/src/pack/import_repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl PackHandler for ImportRepo {
let entry = c.into();
entry_tx.send(entry).await.unwrap();
}
Err(err) => eprintln!("Error: {:?}", err),
Err(err) => eprintln!("Error: {err:?}"),
}
}
tracing::info!("send commits end");
Expand All @@ -135,7 +135,7 @@ impl PackHandler for ImportRepo {
let entry = t.into();
entry_tx.send(entry).await.unwrap();
}
Err(err) => eprintln!("Error: {:?}", err),
Err(err) => eprintln!("Error: {err:?}"),
}
}
tracing::info!("send trees end");
Expand All @@ -145,7 +145,7 @@ impl PackHandler for ImportRepo {
while let Some(model) = bid_stream.next().await {
match model {
Ok(m) => bids.push(m.blob_id),
Err(err) => eprintln!("Error: {:?}", err),
Err(err) => eprintln!("Error: {err:?}"),
}
}

Expand All @@ -164,7 +164,7 @@ impl PackHandler for ImportRepo {
let entry: Entry = b.into();
sender_clone.send(entry).await.unwrap();
}
Err(err) => eprintln!("Error: {:?}", err),
Err(err) => eprintln!("Error: {err:?}"),
}
}
// });
Expand Down Expand Up @@ -383,7 +383,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()],
&format!("\n{}", commit_msg),
&format!("\n{commit_msg}"),
);

let save_trees: Vec<mega_tree::ActiveModel> = save_trees
Expand Down Expand Up @@ -415,7 +415,7 @@ mod test {
let path = PathBuf::from("/third-party/crates/tokio/tokio-console");
let ancestors: Vec<_> = path.ancestors().collect();
for path in ancestors.into_iter() {
println!("{:?}", path);
println!("{path:?}");
}
}
}
16 changes: 8 additions & 8 deletions ceres/src/protocol/smart.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ impl SmartProtocol {
"HEAD"
};
let cap_list = match service_type {
ServiceType::UploadPack => format!("{}{}", UPLOAD_CAP_LIST, COMMON_CAP_LIST),
ServiceType::ReceivePack => format!("{}{}", RECEIVE_CAP_LIST, COMMON_CAP_LIST),
ServiceType::UploadPack => format!("{UPLOAD_CAP_LIST}{COMMON_CAP_LIST}"),
ServiceType::ReceivePack => format!("{RECEIVE_CAP_LIST}{COMMON_CAP_LIST}"),
};
let pkt_line = format!("{}{}{}{}{}{}", head_hash, SP, name, NUL, cap_list, LF);
let pkt_line = format!("{head_hash}{SP}{name}{NUL}{cap_list}{LF}");
let mut ref_list = vec![pkt_line];

for git_ref in git_refs {
Expand Down Expand Up @@ -152,7 +152,7 @@ impl SmartProtocol {

for hash in &have {
if pack_handler.check_commit_exist(hash).await {
add_pkt_line_string(&mut protocol_buf, format!("ACK {} common\n", hash));
add_pkt_line_string(&mut protocol_buf, format!("ACK {hash} common\n"));
if last_common_commit.is_empty() {
last_common_commit = hash.to_string();
}
Expand All @@ -174,7 +174,7 @@ impl SmartProtocol {
if self.capabilities.contains(&Capability::NoDone) {
// If multi_ack_detailed and no-done are both present, then the sender is free to immediately send a pack
// following its first "ACK obj-id ready" message.
add_pkt_line_string(&mut protocol_buf, format!("ACK {} ready\n", hash));
add_pkt_line_string(&mut protocol_buf, format!("ACK {hash} ready\n"));
}
}
} else {
Expand All @@ -183,7 +183,7 @@ impl SmartProtocol {
let (_, rx) = tokio::sync::mpsc::channel::<Vec<u8>>(1);
pack_data = ReceiverStream::new(rx);
}
add_pkt_line_string(&mut protocol_buf, format!("ACK {} \n", last_common_commit));
add_pkt_line_string(&mut protocol_buf, format!("ACK {last_common_commit} \n"));
}
Ok((pack_data, protocol_buf))
}
Expand Down Expand Up @@ -299,7 +299,7 @@ impl SmartProtocol {
pub fn build_smart_reply(&self, ref_list: &Vec<String>, service: String) -> BytesMut {
let mut pkt_line_stream = BytesMut::new();
if self.transport_protocol == TransportProtocol::Http {
add_pkt_line_string(&mut pkt_line_stream, format!("# service={}\n", service));
add_pkt_line_string(&mut pkt_line_stream, format!("# service={service}\n"));
pkt_line_stream.put(&PKT_LINE_END_MARKER[..]);
}

Expand Down Expand Up @@ -385,7 +385,7 @@ pub fn read_pkt_line(bytes: &mut Bytes) -> (usize, Bytes) {
}
let pkt_length = bytes.copy_to_bytes(4);
let pkt_length = usize::from_str_radix(core::str::from_utf8(&pkt_length).unwrap(), 16)
.unwrap_or_else(|_| panic!("{:?} is not a valid digit?", pkt_length));
.unwrap_or_else(|_| panic!("{pkt_length:?} is not a valid digit?"));
if pkt_length == 0 {
return (0, Bytes::new());
}
Expand Down
10 changes: 5 additions & 5 deletions common/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ impl Default for Config {
.lines()
.map(|line| {
if line.starts_with("base_dir ") {
format!("base_dir = {:?}", base_dir)
format!("base_dir = {base_dir:?}")
} else {
line.to_string()
}
Expand Down Expand Up @@ -257,7 +257,7 @@ fn traverse_config(key: &str, value: &c::Value, f: &impl Fn(&str, &c::Value)) {
let new_key = if key.is_empty() {
k.clone()
} else {
format!("{}.{}", key, k)
format!("{key}.{k}")
};
traverse_config(&new_key, v, f);
}
Expand Down Expand Up @@ -424,7 +424,7 @@ impl PackConfig {
let percentage: f64 = size_str
.trim_end_matches('%')
.parse()
.map_err(|_| format!("Invalid percentage: {}", size_str))?;
.map_err(|_| format!("Invalid percentage: {size_str}"))?;
let total_mem = fn_get_total_capacity()?;

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

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

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

Ok(bytes as usize)
Expand Down
2 changes: 1 addition & 1 deletion common/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl FromStr for SupportOauthType {
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"github" => Ok(Self::GitHub),
_ => Err(format!("'{}' is not a valid oauth type", s)),
_ => Err(format!("'{s}' is not a valid oauth type")),
}
}
}
11 changes: 5 additions & 6 deletions common/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn generate_rich_text(content: &str) -> String {
}

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

/// Format commit message with GPG signature<br>
Expand All @@ -54,10 +54,10 @@ pub fn mr_ref_name(mr_link: &str) -> String {
pub fn format_commit_msg(msg: &str, gpg_sig: Option<&str>) -> String {
match gpg_sig {
None => {
format!("\n{}", msg)
format!("\n{msg}")
}
Some(gpg) => {
format!("{}\n\n{}", gpg, msg)
format!("{gpg}\n\n{msg}")
}
}
}
Expand Down Expand Up @@ -96,8 +96,7 @@ pub fn check_conventional_commits_message(msg: &str) -> bool {
let unicode_pattern = r"\p{L}\p{N}\p{P}\p{S}\p{Z}";
// type only support characters&numbers, others fields support all unicode characters
let regex_str = format!(
r"^(?P<type>[\p{{L}}\p{{N}}_-]+)(?:\((?P<scope>[{unicode}]+)\))?!?: (?P<description>[{unicode}]+)$",
unicode = unicode_pattern
r"^(?P<type>[\p{{L}}\p{{N}}_-]+)(?:\((?P<scope>[{unicode_pattern}]+)\))?!?: (?P<description>[{unicode_pattern}]+)$",
);

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

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

// println!("{}({}): {}\n{}", commit_type, scope.unwrap_or("None".to_string()), description.unwrap(), body_footer);
Expand Down
4 changes: 2 additions & 2 deletions gateway/src/api/github_router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ async fn webhook(
/// GitHub API: Get the files change of a pull request. <br>
/// For read-only operation of public repos, no authentication is required.
pub async fn get_pr_files(pr_url: &str) -> Value {
get_request(&format!("{}/files", pr_url)).await
get_request(&format!("{pr_url}/files")).await
}

/// GitHub API: Get the commits of a pull request.
pub async fn get_pr_commits(pr_url: &str) -> Value {
get_request(&format!("{}/commits", pr_url)).await
get_request(&format!("{pr_url}/commits")).await
}
/// Send a GET request to the given URL and return the JSON response.
async fn get_request(url: &str) -> Value {
Expand Down
4 changes: 2 additions & 2 deletions gateway/src/https_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub async fn http_server(context: AppContext, options: HttpOptions) {

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

let server_url = format!("{}:{}", host, port);
let server_url = format!("{host}:{port}");

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

let mega_api_state = MegaApiServiceState {
Expand Down
2 changes: 1 addition & 1 deletion gemini/src/ca/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ fn _is_reserved_key(name: String) -> bool {
}

fn add_user_key_pre(name: String) -> String {
format!("{}{}", USER_KEY_PRE, name)
format!("{USER_KEY_PRE}{name}")
}

pub fn get_cert_name_from_path(path: &str) -> Option<String> {
Expand Down
9 changes: 4 additions & 5 deletions gemini/src/lfs/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ pub async fn share_lfs(
let json = serde_json::to_string(&lfs).unwrap();

let client = Client::new();
let url = format!("{}/api/v1/lfs_share", bootstrap_node);
let url = format!("{bootstrap_node}/api/v1/lfs_share");
let response = client
.post(url)
.header("content-type", "application/json")
Expand Down Expand Up @@ -79,21 +79,20 @@ pub async fn share_lfs(
///
pub async fn get_lfs_chunks_info(bootstrap_node: String, file_hash: String) -> Option<LFSInfoRes> {
let url = format!(
"{}/api/v1/lfs_chunk?file_hash={}",
bootstrap_node, file_hash
"{bootstrap_node}/api/v1/lfs_chunk?file_hash={file_hash}"
);
let lfs_info: LFSInfoRes = match get(url.clone()).await {
Ok(response) => {
if !response.status().is_success() {
println!("Get lfs chuncks info failed {}", url);
println!("Get lfs chuncks info failed {url}");
return None;
}
let body = response.text().await.unwrap();
let lfs_info: LFSInfoRes = serde_json::from_str(&body).unwrap();
lfs_info
}
Err(_) => {
println!("Get lfs chuncks info failed {}", url);
println!("Get lfs chuncks info failed {url}");
return None;
}
};
Expand Down
11 changes: 4 additions & 7 deletions gemini/src/p2p/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl P2PRelay {

pub async fn run(&self, host: String, port: u16) -> Result<()> {
let server_config = self.get_server_config().await?;
let addr = format!("{}:{}", host, port);
let addr = format!("{host}:{port}");
let endpoint =
quinn::Endpoint::server(server_config, SocketAddr::from_str(addr.as_str()).unwrap())?;
info!("Quic server listening on udp {}", endpoint.local_addr()?);
Expand Down Expand Up @@ -670,7 +670,7 @@ impl P2PRelay {
"File handle receive, target_id:{}, from:{}, file_path:{}",
target_id, from, git_path
);
let key = format!("git-clone-{}-{}", target_id, from);
let key = format!("git-clone-{target_id}-{from}");

if let Some(target_conn) = self.git_objects_connection_map.get(&key) {
info!("Find target connection to {}", target_id);
Expand Down Expand Up @@ -708,11 +708,8 @@ impl P2PRelay {
let header = String::from_utf8_lossy(&header_buf[..len]);
let header: LFSHeader = serde_json::from_str(&header)?;
let (target_id, from, oid, size) = (header.target, header.from, header.oid, header.size);
info!(
"LFS handle receive, target_id:{}, from:{}, oid:{}: size:{}",
target_id, from, oid, size
);
let key = format!("lfs-{}-{}", target_id, from);
info!("LFS handle receive, target_id:{target_id}, from:{from}, oid:{oid}: size:{size}");
let key = format!("lfs-{target_id}-{from}");

if let Some(target_conn) = self.lfs_connection_map.get(&key) {
info!("Find target connection to {}", target_id);
Expand Down
6 changes: 3 additions & 3 deletions gemini/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn get_available_port() -> Result<u16, String> {
let port = listener.local_addr().unwrap().port();
Ok(port)
}
Err(e) => Err(format!("Failed to bind to a port: {}", e)),
Err(e) => Err(format!("Failed to bind to a port: {e}")),
}
}

Expand Down Expand Up @@ -101,12 +101,12 @@ pub fn parse_pointer_data(data: &[u8]) -> Option<(String, u64)> {
}
// Start with format `version ...`
if let Some(data) =
data.strip_prefix(format!("version {}\noid {}:", LFS_VERSION, LFS_HASH_ALGO).as_bytes())
data.strip_prefix(format!("version {LFS_VERSION}\noid {LFS_HASH_ALGO}:").as_bytes())
{
if data.len() > LFS_OID_LEN && data[LFS_OID_LEN] == b'\n' {
// check `oid` length
let oid = String::from_utf8(data[..LFS_OID_LEN].to_vec()).unwrap();
if let Some(data) = data.strip_prefix(format!("{}\nsize ", oid).as_bytes()) {
if let Some(data) = data.strip_prefix(format!("{oid}\nsize ").as_bytes()) {
let data = String::from_utf8(data[..].to_vec()).unwrap();
if let Ok(size) = data.trim_end().parse::<u64>() {
return Some((oid, size));
Expand Down
14 changes: 11 additions & 3 deletions jupiter/README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
## Jupiter Module - Monorepo and Mega Database Storage Engine

### Migration Guideline
1. Generate entity files
1. Generate new migration

```bash

cd mega/jupiter/src

sea-orm-cli migrate generate
```

2. Generate entity files

```bash

cd mega/jupiter/src/migration
cd mega/jupiter/src

sea-orm-cli generate entity -u postgres://postgres:postgres@localhost:5432/mono -o ../callisto/src --with-serde both

```

2. Running Migrator CLI
3. Running Migrator CLI

- Generate a new migration file
```sh
Expand Down
Loading
Loading