mirror of
https://forge.pointfixe.fr/hubert/gitust.git
synced 2026-02-04 16:17:30 +01:00
base
This commit is contained in:
68
src/git.rs
Normal file
68
src/git.rs
Normal 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)}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user