aboutsummaryrefslogtreecommitdiff
path: root/supergit/src/raw/mod.rs
blob: b2f67a450b35db799f8461028573350618a90de5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Raw representation wrappers for libgit2

use git2::{self, Repository};

pub(crate) type RawResult<T> = Result<T, RawError>;

/// An error abstraction for raw git operations
#[derive(Debug)]
pub(crate) enum RawError {
    AllBad,
}

impl From<git2::Error> for RawError {
    fn from(_: git2::Error) -> Self {
        Self::AllBad
    }
}

/// Wrap a libgit2 repository to provide an API fascade
pub(crate) struct RawRepository {
    inner: Repository,
}

impl RawRepository {
    pub(crate) 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(())
    }
}