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
369 changes: 151 additions & 218 deletions docs/development.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions mega/tests/common/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// use `common/mod.rs` rather than `common.rs`, to declare it's not a test file
18 changes: 9 additions & 9 deletions mega/tests/lfs_test.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
mod common;

/// integration tests for the mega module
use std::process::Command;
use std::{env, fs, io, thread};
use std::io::Write;
use std::net::TcpStream;
use std::path::Path;
use std::time::Duration;
use rand::Rng;
use tempfile::TempDir;

Expand All @@ -27,23 +31,19 @@ fn run_git_cmd(args: &[&str]) {
}

fn is_port_in_use(port: u16) -> bool {
let output = Command::new("lsof")
.arg(format!("-i:{}", port))
.output()
.expect("Failed to execute command");

!output.stdout.is_empty()
TcpStream::connect_timeout(&format!("127.0.0.1:{}", port).parse().unwrap(), Duration::from_millis(1000))
.is_ok()
}

fn run_mega_server() {
thread::spawn(|| {
let args = vec!["service", "multi", "http"];
mega::cli::parse(Some(args)).expect("Failed to start mega service");
});
// loop check until 8000 port to be ready
// loop check until port to be ready
let mut i = 0;
while !is_port_in_use(PORT) && (i < 10) {
thread::sleep(std::time::Duration::from_secs(1));
while !is_port_in_use(PORT) && (i < 15) {
thread::sleep(Duration::from_secs(1));
i += 1;
}
assert!(is_port_in_use(PORT), "mega server not started");
Expand Down
8 changes: 4 additions & 4 deletions mercury/src/internal/object/commit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ use crate::internal::object::ObjectType;
/// The `Commit` struct is used to represent a commit object.
///
/// - The tree object SHA points to the top level tree for this commit, which reflects the complete
/// state of the repository at the time of the commit. The tree object in turn points to blobs and
/// subtrees which represent the files in the repository.
/// state of the repository at the time of the commit. The tree object in turn points to blobs and
/// subtrees which represent the files in the repository.
/// - The parent commit SHAs allow Git to construct a linked list of commits and build the full
/// commit history. By chaining together commits in this fashion, Git is able to represent the entire
/// history of a repository with a single commit object at its root.
/// commit history. By chaining together commits in this fashion, Git is able to represent the entire
/// history of a repository with a single commit object at its root.
/// - The author and committer fields contain the name, email address, timestamp and timezone.
/// - The message field contains the commit message, which maybe include signed or DCO.
#[allow(unused)]
Expand Down
4 changes: 2 additions & 2 deletions mercury/src/internal/object/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
//! - Name: The name of the author, encoded as a UTF-8 string.
//! - Email: The email address of the author, encoded as a UTF-8 string.
//! - Timestamp: The timestamp of when the commit was authored, encoded as a decimal number of seconds
//! since the Unix epoch (January 1, 1970, 00:00:00 UTC).
//! since the Unix epoch (January 1, 1970, 00:00:00 UTC).
//! - Timezone: The timezone offset of the author's local time from Coordinated Universal Time (UTC),
//! encoded as a string in the format "+HHMM" or "-HHMM".
//! encoded as a string in the format "+HHMM" or "-HHMM".
//!
use std::{fmt::Display, str::FromStr};

Expand Down
4 changes: 2 additions & 2 deletions mercury/src/internal/object/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ impl TreeItemMode {
/// <mode> <name>\0<binary object ID>
/// ```
/// - `<mode>` is the mode of the object, represented as a six-digit octal number. The first digit
/// represents the object type (tree, blob, etc.), and the remaining digits represent the file mode or permissions.
/// represents the object type (tree, blob, etc.), and the remaining digits represent the file mode or permissions.
/// - `<name>` is the name of the object.
/// - `\0` is a null byte separator.
/// - `<binary object ID>` is the ID of the object that represents the contents of the file or
/// directory, represented as a binary SHA-1 hash.
/// directory, represented as a binary SHA-1 hash.
///
/// # Example
/// ```bash
Expand Down
8 changes: 4 additions & 4 deletions mercury/src/internal/object/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use crate::errors::GitError;
/// * `Blob` (1): A Git object that stores the content of a file.
/// * `Tree` (2): A Git object that represents a directory or a folder in a Git repository.
/// * `Commit` (3): A Git object that represents a commit in a Git repository, which contains
/// information such as the author, committer, commit message, and parent commits.
/// information such as the author, committer, commit message, and parent commits.
/// * `Tag` (4): A Git object that represents a tag in a Git repository, which is used to mark a
/// specific point in the Git history.
/// specific point in the Git history.
/// * `OffsetDelta` (6): A Git object that represents a delta between two objects, where the delta
/// is stored as an offset to the base object.
/// is stored as an offset to the base object.
/// * `HashDelta` (7): A Git object that represents a delta between two objects, where the delta
/// is stored as a hash of the base object.
/// is stored as a hash of the base object.
///
/// By assigning unique integer values to each Git object type, Git can easily and efficiently
/// identify the type of an object and perform the appropriate operations on it. when parsing a Git
Expand Down
6 changes: 3 additions & 3 deletions mercury/src/internal/pack/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ impl Drop for Pack {
impl Pack {
/// # Parameters
/// - `thread_num`: The number of threads to use for decoding and cache, `None` mean use the number of logical CPUs.
/// It can't be zero, or panic <br>
/// It can't be zero, or panic <br>
/// - `mem_limit`: The maximum size of the memory cache in bytes, or None for unlimited.
/// The 80% of it will be used for [Caches] <br>
/// The 80% of it will be used for [Caches] <br>
/// **Not very accurate, because of memory alignment and other reasons, overuse about 15%** <br>
/// - `temp_path`: The path to a directory for temporary files, default is "./.cache_temp" <br>
/// For example, thread_num = 4 will use up to 8 threads (4 for decoding and 4 for cache) <br>
/// For example, thread_num = 4 will use up to 8 threads (4 for decoding and 4 for cache) <br>
/// - `clean_tmp`: whether to remove temp dir
///
pub fn new(thread_num: Option<usize>, mem_limit: Option<usize>, temp_path: Option<PathBuf>, clean_tmp: bool) -> Self {
Expand Down
4 changes: 3 additions & 1 deletion scorpio/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ sea-orm = { version= "0.12.15",features = [
] }
once_cell = "1.19.0"
tokio = { version = "1.38.1", features = ["full"] }


[features]
async-io = []

[workspace]