This commit is contained in:
2021-07-01 06:52:04 +02:00
parent baf85e997c
commit dcae2950e3
7 changed files with 399 additions and 0 deletions

68
src/git.rs Normal file
View File

@@ -0,0 +1,68 @@
use std::fmt::{Display, Formatter, Result};
pub struct GitRepo {}
impl GitRepo {
pub fn new() -> GitRepo {
GitRepo{}
}
pub async fn browse(&self, commit : &GitCommit, dir: &GitBrowseDir) -> Vec<GitBrowseEntry> {
vec!(GitBrowseEntry::EGitDir(GitBrowseDir("src/".to_string())), GitBrowseEntry::EGitFile(GitBrowseFile("pom.xml".to_string())))
}
}
#[derive(Debug)]
pub struct GitCommit (String);
impl GitCommit {
pub fn new(s : String) -> GitCommit {
GitCommit(s)
}
}
impl Display for GitCommit {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "{}", self.0)
}
}
#[derive(Debug)]
pub struct GitBrowseFile (String);
#[derive(Debug)]
pub struct GitBrowseDir (String);
impl GitBrowseDir {
pub fn new(s : String) -> GitBrowseDir {
GitBrowseDir(s)
}
}
impl Display for GitBrowseFile {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "{}", self.0)
}
}
impl Display for GitBrowseDir {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
write!(f, "{}", self.0)
}
}
#[derive(Debug)]
pub enum GitBrowseEntry {
EGitFile(GitBrowseFile),
EGitDir(GitBrowseDir)
}
impl Display for GitBrowseEntry {
fn fmt(&self, f: &mut Formatter<'_>) -> Result {
match self {
GitBrowseEntry::EGitFile(file) => {write!(f, "{}", file)}
GitBrowseEntry::EGitDir(dir) => {write!(f, "{}", dir)}
}
}
}