mirror of
https://github.com/MrBeanCpp/MIT.git
synced 2026-02-03 10:14:13 +08:00
重新format,对use进行排序
This commit is contained in:
15
rustfmt.toml
15
rustfmt.toml
@@ -6,13 +6,22 @@ struct_lit_width = 60
|
||||
chain_width = 80
|
||||
single_line_if_else_max_width = 60
|
||||
single_line_let_else_max_width = 60
|
||||
|
||||
merge_derives = true
|
||||
reorder_imports = true
|
||||
|
||||
unstable_features = true # 使能 unstable 特性
|
||||
## unstable features below ##
|
||||
# 格式化注释代码块:Unstable
|
||||
format_code_in_doc_comments = true
|
||||
|
||||
|
||||
# 重新排序mod
|
||||
reorder_modules = true
|
||||
# 按照 crate 重新排序
|
||||
imports_granularity = "Crate"
|
||||
# 过长换行使用大括号
|
||||
match_arm_blocks = true
|
||||
# 数组换行
|
||||
indent_style = "Block"
|
||||
# 彩色输出:Unstable
|
||||
color = "Auto"
|
||||
# 忽略,也是 unstable 特性
|
||||
ignore = ["tests"]
|
||||
|
||||
11
src/cli.rs
11
src/cli.rs
@@ -1,12 +1,7 @@
|
||||
use clap::{ArgGroup, Parser, Subcommand};
|
||||
use mit::commands::add::add;
|
||||
use mit::commands::branch::branch;
|
||||
use mit::commands::commit::commit;
|
||||
use mit::commands::init::init;
|
||||
use mit::commands::log::log;
|
||||
use mit::commands::remove::remove;
|
||||
use mit::commands::status::status;
|
||||
use mit::commands::switch::switch;
|
||||
use mit::commands::{
|
||||
add::add, branch::branch, commit::commit, init::init, log::log, remove::remove, status::status, switch::switch,
|
||||
};
|
||||
|
||||
/// Rust实现的简易版本的Git,用于学习Rust语言
|
||||
#[derive(Parser)]
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
use std::env;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{
|
||||
env,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use colored::Colorize;
|
||||
|
||||
use crate::models::blob::Blob;
|
||||
use crate::models::index::{FileMetaData, Index};
|
||||
use crate::utils::util::{
|
||||
check_repo_exist, get_working_dir, is_inside_repo, is_inside_workdir, list_files, to_workdir_relative_path,
|
||||
ROOT_DIR,
|
||||
use crate::{
|
||||
models::{
|
||||
blob::Blob,
|
||||
index::{FileMetaData, Index},
|
||||
},
|
||||
utils::util::{
|
||||
check_repo_exist, get_working_dir, is_inside_repo, is_inside_workdir, list_files, to_workdir_relative_path,
|
||||
ROOT_DIR,
|
||||
},
|
||||
};
|
||||
|
||||
pub fn add(files: Vec<String>, all: bool, mut update: bool) {
|
||||
|
||||
@@ -127,8 +127,7 @@ pub fn branch(
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use super::*;
|
||||
use crate::commands;
|
||||
use crate::utils::util;
|
||||
use crate::{commands, utils::util};
|
||||
#[test]
|
||||
fn test_create_branch() {
|
||||
util::setup_test_with_clean_mit();
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
use crate::head;
|
||||
use crate::models::{commit, index};
|
||||
use crate::{
|
||||
head,
|
||||
models::{commit, index},
|
||||
};
|
||||
|
||||
use super::status;
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use crate::models::index::Index;
|
||||
use crate::utils::util;
|
||||
use crate::utils::util::check_repo_exist;
|
||||
use crate::{
|
||||
models::index::Index,
|
||||
utils::{util, util::check_repo_exist},
|
||||
};
|
||||
use colored::Colorize;
|
||||
use std::path::PathBuf;
|
||||
use std::{fs, io};
|
||||
use std::{fs, io, path::PathBuf};
|
||||
|
||||
/// 从暂存区&|工作区删除文件
|
||||
pub fn remove(files: Vec<String>, cached: bool, recursive: bool) -> io::Result<()> {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
use crate::head::Head;
|
||||
use crate::models::commit::Commit;
|
||||
use crate::models::index::Index;
|
||||
use crate::utils::util::check_repo_exist;
|
||||
use crate::{head, utils::util};
|
||||
use crate::{
|
||||
head,
|
||||
head::Head,
|
||||
models::{commit::Commit, index::Index},
|
||||
utils::{util, util::check_repo_exist},
|
||||
};
|
||||
use colored::Colorize;
|
||||
use std::path::PathBuf;
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
use crate::models::object::Hash;
|
||||
use crate::store::Store;
|
||||
use crate::utils::util::calc_hash;
|
||||
use std::fs;
|
||||
use std::path::Path;
|
||||
use crate::{models::object::Hash, store::Store, utils::util::calc_hash};
|
||||
use std::{fs, path::Path};
|
||||
|
||||
/**
|
||||
Blob
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
use crate::models::blob::Blob;
|
||||
use crate::models::object::Hash;
|
||||
use crate::utils::util;
|
||||
use crate::utils::util::get_relative_path;
|
||||
use crate::{
|
||||
models::{blob::Blob, object::Hash},
|
||||
utils::{util, util::get_relative_path},
|
||||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::time::SystemTime;
|
||||
use std::{
|
||||
collections::HashMap,
|
||||
fs,
|
||||
path::{Path, PathBuf},
|
||||
time::SystemTime,
|
||||
};
|
||||
|
||||
// 文件元数据结构
|
||||
#[derive(Serialize, Deserialize, Debug, Clone)]
|
||||
|
||||
@@ -150,9 +150,10 @@ impl Tree {
|
||||
mod test {
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::models::blob::Blob;
|
||||
use crate::models::index::FileMetaData;
|
||||
use crate::utils::util;
|
||||
use crate::{
|
||||
models::{blob::Blob, index::FileMetaData},
|
||||
utils::util,
|
||||
};
|
||||
#[test]
|
||||
fn test_new() {
|
||||
util::setup_test_with_clean_mit();
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
use sha1::{Digest, Sha1};
|
||||
use std::io::Write;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::{fs, io, option};
|
||||
use std::{
|
||||
fs, io,
|
||||
io::Write,
|
||||
option,
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
pub const ROOT_DIR: &str = ".mit";
|
||||
pub const TEST_DIR: &str = "mit_test_storage"; // 执行测试的储存库
|
||||
|
||||
Reference in New Issue
Block a user