Add basic module setup
This commit is contained in:
parent
e385927316
commit
07a3a32265
11 changed files with 108 additions and 0 deletions
|
@ -26,4 +26,5 @@ extern crate libimagentrylink;
|
||||||
pub mod debug;
|
pub mod debug;
|
||||||
pub mod flock;
|
pub mod flock;
|
||||||
pub mod linkverify;
|
pub mod linkverify;
|
||||||
|
pub mod vcs;
|
||||||
|
|
||||||
|
|
0
libimagstorestdhook/src/vcs/git/config.rs
Normal file
0
libimagstorestdhook/src/vcs/git/config.rs
Normal file
0
libimagstorestdhook/src/vcs/git/create.rs
Normal file
0
libimagstorestdhook/src/vcs/git/create.rs
Normal file
0
libimagstorestdhook/src/vcs/git/delete.rs
Normal file
0
libimagstorestdhook/src/vcs/git/delete.rs
Normal file
80
libimagstorestdhook/src/vcs/git/error.rs
Normal file
80
libimagstorestdhook/src/vcs/git/error.rs
Normal file
|
@ -0,0 +1,80 @@
|
||||||
|
use std::error::Error;
|
||||||
|
use std::fmt::Error as FmtError;
|
||||||
|
use std::clone::Clone;
|
||||||
|
use std::fmt::{Display, Formatter};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Kind of error
|
||||||
|
*/
|
||||||
|
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||||
|
pub enum GitHookErrorKind {
|
||||||
|
}
|
||||||
|
|
||||||
|
fn githook_error_type_as_str(e: &GitHookErrorKind) -> &'static str {
|
||||||
|
match *e {
|
||||||
|
_ => "",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for GitHookErrorKind {
|
||||||
|
|
||||||
|
fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> {
|
||||||
|
try!(write!(fmt, "{}", githook_error_type_as_str(self)));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Store error type
|
||||||
|
*/
|
||||||
|
#[derive(Debug)]
|
||||||
|
pub struct GitHookError {
|
||||||
|
err_type: GitHookErrorKind,
|
||||||
|
cause: Option<Box<Error>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl GitHookError {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Build a new GitHookError from an GitHookErrorKind, optionally with cause
|
||||||
|
*/
|
||||||
|
pub fn new(errtype: GitHookErrorKind, cause: Option<Box<Error>>)
|
||||||
|
-> GitHookError
|
||||||
|
{
|
||||||
|
GitHookError {
|
||||||
|
err_type: errtype,
|
||||||
|
cause: cause,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the error type of this GitHookError
|
||||||
|
*/
|
||||||
|
pub fn err_type(&self) -> GitHookErrorKind {
|
||||||
|
self.err_type.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for GitHookError {
|
||||||
|
|
||||||
|
fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> {
|
||||||
|
try!(write!(fmt, "[{}]", githook_error_type_as_str(&self.err_type.clone())));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Error for GitHookError {
|
||||||
|
|
||||||
|
fn description(&self) -> &str {
|
||||||
|
githook_error_type_as_str(&self.err_type.clone())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn cause(&self) -> Option<&Error> {
|
||||||
|
self.cause.as_ref().map(|e| &**e)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
9
libimagstorestdhook/src/vcs/git/mod.rs
Normal file
9
libimagstorestdhook/src/vcs/git/mod.rs
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
mod config;
|
||||||
|
pub mod create;
|
||||||
|
pub mod delete;
|
||||||
|
mod error;
|
||||||
|
mod result;
|
||||||
|
pub mod retrieve;
|
||||||
|
pub mod update;
|
||||||
|
pub mod util;
|
||||||
|
|
5
libimagstorestdhook/src/vcs/git/result.rs
Normal file
5
libimagstorestdhook/src/vcs/git/result.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
use std::result::Result as RResult;
|
||||||
|
|
||||||
|
use vcs::git::error::GitHookError;
|
||||||
|
|
||||||
|
pub type Result<T> = RResult<T, GitHookError>;
|
0
libimagstorestdhook/src/vcs/git/retrieve.rs
Normal file
0
libimagstorestdhook/src/vcs/git/retrieve.rs
Normal file
0
libimagstorestdhook/src/vcs/git/update.rs
Normal file
0
libimagstorestdhook/src/vcs/git/update.rs
Normal file
12
libimagstorestdhook/src/vcs/git/util.rs
Normal file
12
libimagstorestdhook/src/vcs/git/util.rs
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
//! Utility functionality for integrating git hooks in the store
|
||||||
|
//!
|
||||||
|
//! Contains primitives to create a repository within the store path
|
||||||
|
|
||||||
|
pub fn mkrepo(store: &Store) -> Result<()> {
|
||||||
|
unimplemented!()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn hasrepo(store: &Store) -> bool {
|
||||||
|
Repository::open(store.path()).is_ok()
|
||||||
|
}
|
||||||
|
|
1
libimagstorestdhook/src/vcs/mod.rs
Normal file
1
libimagstorestdhook/src/vcs/mod.rs
Normal file
|
@ -0,0 +1 @@
|
||||||
|
pub mod git;
|
Loading…
Reference in a new issue