format use rustfmt nightly

This commit is contained in:
HouXiaoxuan
2023-12-22 08:41:23 +08:00
parent 80ab4c1052
commit 758cc334eb
5 changed files with 11 additions and 22 deletions

View File

@@ -1,9 +1,9 @@
pub mod add;
pub mod branch;
pub mod commit;
pub mod init;
pub mod remove;
pub mod status;
pub mod log;
pub mod branch;
pub mod remove;
pub mod restore;
pub mod status;
pub mod switch;
pub mod restore;

View File

@@ -0,0 +1 @@

View File

@@ -8,10 +8,7 @@ pub enum Head {
pub fn current_head() -> Head {
let mut head = util::get_storage_path().unwrap();
head.push("HEAD");
let head_content = std::fs::read_to_string(head)
.expect("HEAD文件损坏")
.trim_end()
.to_string(); //去除末尾\n
let head_content = std::fs::read_to_string(head).expect("HEAD文件损坏").trim_end().to_string(); //去除末尾\n
if head_content.starts_with("ref: refs/heads/") {
let branch_name = head_content.trim_start_matches("ref: refs/heads/");
Head::Branch(branch_name.to_string())
@@ -53,7 +50,7 @@ pub fn delete_branch(branch_name: &String) {
}
}
/**返回当前head指向的commit hash如果是分支则返回分支的commit hash*/
/**返回当前head指向的commit hash如果是分支则返回分支的commit hash */
pub fn current_head_commit() -> String {
let head = current_head();
match head {
@@ -65,7 +62,7 @@ pub fn current_head_commit() -> String {
}
}
/** 将当前的head指向commit_hash根据当前的head类型更新不同的文件 */
/** 将当前的head指向commit_hash根据当前的head类型更新不同的文件 */
pub fn update_head_commit(commit_hash: &String) {
let head = current_head();
match head {

View File

@@ -52,17 +52,8 @@ fn store_path_to_tree(path_entries: &Vec<PathBuf>, current_root: PathBuf) -> Tre
continue;
}
// 拿到下一级别目录
let process_path = path
.components()
.nth(0)
.unwrap()
.as_os_str()
.to_str()
.unwrap();
if processed_path
.insert(process_path.to_string(), true)
.is_some()
{
let process_path = path.components().nth(0).unwrap().as_os_str().to_str().unwrap();
if processed_path.insert(process_path.to_string(), true).is_some() {
continue;
}

View File

@@ -32,7 +32,7 @@ impl Store {
path.exists()
}
/** 根据前缀搜索,有歧义时返回 None*/
/** 根据前缀搜索,有歧义时返回 None */
pub fn search(&self, hash: &String) -> Option<Hash> {
if hash.is_empty() {
return None;