mirror of
https://github.com/MrBeanCpp/MIT.git
synced 2026-02-03 18:33:46 +08:00
format use rustfmt nightly
This commit is contained in:
@@ -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;
|
||||
@@ -0,0 +1 @@
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ impl Store {
|
||||
path.exists()
|
||||
}
|
||||
|
||||
/** 根据前缀搜索,有歧义时返回 None*/
|
||||
/** 根据前缀搜索,有歧义时返回 None */
|
||||
pub fn search(&self, hash: &String) -> Option<Hash> {
|
||||
if hash.is_empty() {
|
||||
return None;
|
||||
|
||||
Reference in New Issue
Block a user