diff options
author | Katharina Fey <kookie@spacekookie.de> | 2020-10-27 15:15:23 +0100 |
---|---|---|
committer | Katharina Fey <kookie@spacekookie.de> | 2020-10-27 15:15:23 +0100 |
commit | 623954d19fdf0dca47db319e5c88ee561aa8d25c (patch) | |
tree | 11484edce6ecdff5f43f9533ede17aa56d54d087 /supergit/src/raw | |
parent | aadac179feea5bcdab8e27683be376028ac4df9c (diff) |
Diffstat (limited to 'supergit/src/raw')
-rw-r--r-- | supergit/src/raw/branch_walk.rs | 18 | ||||
-rw-r--r-- | supergit/src/raw/mod.rs | 25 |
2 files changed, 32 insertions, 11 deletions
diff --git a/supergit/src/raw/branch_walk.rs b/supergit/src/raw/branch_walk.rs index dfc7485..d4232c4 100644 --- a/supergit/src/raw/branch_walk.rs +++ b/supergit/src/raw/branch_walk.rs @@ -1 +1,19 @@ //! Walk along a branch parsing commit metadata + +use std::collections::{BTreeMap, BTreeSet}; + +pub struct CommitHistory { + /// The correct order of commit IDs + order: Vec<String>, + /// Map of commit IDs to commit metadata + meta: BTreeMap<String, CommitNode>, +} + +pub struct CommitNode { + id: String, + author: String, + commiter: String, + message: String, + touches: BTreeSet<String>, + time: u64, +} diff --git a/supergit/src/raw/mod.rs b/supergit/src/raw/mod.rs index 98602ca..7bf6c0a 100644 --- a/supergit/src/raw/mod.rs +++ b/supergit/src/raw/mod.rs @@ -3,13 +3,14 @@ mod branch_walk; mod tree_walk; +use crate::{Branch, BranchCommit}; use git2::{self, Repository}; -pub(crate) type RawResult<T> = Result<T, RawError>; +pub type RawResult<T> = Result<T, RawError>; /// An error abstraction for raw git operations #[derive(Debug)] -pub(crate) enum RawError { +pub enum RawError { AllBad, } @@ -19,24 +20,26 @@ impl From<git2::Error> for RawError { } } +/// Represent a raw branch +pub struct RawBranch { + name: String, + head: String, +} + /// Wrap a libgit2 repository to provide an API fascade -pub(crate) struct RawRepository { +pub struct RawRepository { inner: Repository, } impl RawRepository { - pub(crate) fn open(path: &str) -> RawResult<Self> { + pub fn open(path: &str) -> RawResult<Self> { Ok(Self { inner: Repository::open(path)?, }) } - /// Sync the backing storage with the backing git repo - /// - /// This function can be invoked manually, but should be invoked - /// basically every time your program expects changes to have - /// happened. Polling this function is not recommended. - pub(crate) fn update(&self) -> RawResult<()> { - Ok(()) + /// Parse branch data from repository + pub fn parse_branches(&self) -> RawResult<Vec<RawBranch>> { + todo!() } } |