mirror of
https://github.com/MrBeanCpp/MIT.git
synced 2026-02-04 10:54:47 +08:00
实现一些数据结构
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
use crate::objects::object::Hash;
|
||||
/*Blob
|
||||
* Blob是git中最基本的对象,他储存一份文件的内容,并使用hash作为标识符。
|
||||
*/
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Blob {
|
||||
hash: Hash,
|
||||
data: String,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
use super::object::Hash;
|
||||
/*Commit
|
||||
* git中版本控制的单位。
|
||||
* 一份Commit中对应一份版Tree,记录了该版本所包含的文件;parent记录本次commit的来源,形成了版本树;
|
||||
* 此外,Commit中还包含了作者、提交者、提交信息等。
|
||||
*/
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Commit {
|
||||
hash: Hash,
|
||||
author: String, // unimplemented ignore
|
||||
committer: String, // unimplemented ignore
|
||||
message: String,
|
||||
parent: Vec<Hash>, // parents commit hash
|
||||
tree: String, // tree hash
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
use super::object::Hash;
|
||||
/*Tree
|
||||
* Tree是一个版本中所有文件的集合。从根目录还是,每个目录是一个Tree,每个文件是一个Blob。Tree之间互相嵌套表示文件的层级关系。
|
||||
* 每一个Tree对象也是对应到git储存仓库的一个文件,其内容是一个或多个TreeEntry。
|
||||
*/
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct TreeEntry {
|
||||
pub filemode: (String, String), // (type, mode), type: blob or tree; mode: 100644 or 04000
|
||||
pub hash: Hash, // blob hash or tree hash
|
||||
pub name: String, // file name
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Tree {
|
||||
pub hash: Hash,
|
||||
pub entries: Vec<TreeEntry>,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user