From 20d938877b1a1f8c01fa2ab34f01522ffcba1411 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 15 May 2016 00:13:22 +0200 Subject: [PATCH 001/239] Add dependency: git2 --- libimagstorestdhook/Cargo.toml | 1 + libimagstorestdhook/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libimagstorestdhook/Cargo.toml b/libimagstorestdhook/Cargo.toml index b9bda7f3..7699244a 100644 --- a/libimagstorestdhook/Cargo.toml +++ b/libimagstorestdhook/Cargo.toml @@ -7,6 +7,7 @@ authors = ["Matthias Beyer "] toml = "0.2.*" log = "0.3" fs2 = "0.2" +git2 = "0.4" [dependencies.libimagstore] path = "../libimagstore" diff --git a/libimagstorestdhook/src/lib.rs b/libimagstorestdhook/src/lib.rs index bb01b9c5..2eee0156 100644 --- a/libimagstorestdhook/src/lib.rs +++ b/libimagstorestdhook/src/lib.rs @@ -17,6 +17,7 @@ #[macro_use] extern crate log; extern crate toml; extern crate fs2; +extern crate git2; extern crate libimagstore; extern crate libimagentrylink; From fcc0fce80aa87d44a1a4816798821b6f3e1409b3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 30 Jun 2016 09:07:34 +0200 Subject: [PATCH 002/239] Add dependencies for imag: openssl, zlib, cmake --- default.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/default.nix b/default.nix index 3a57f1cb..e7f4bc28 100644 --- a/default.nix +++ b/default.nix @@ -5,6 +5,12 @@ let rustc cargo ]; + + dependencies = with pkgs; [ + openssl + zlib + cmake + ]; in pkgs.stdenv.mkDerivation rec { @@ -12,7 +18,7 @@ pkgs.stdenv.mkDerivation rec { src = ./.; version = "0.0.0"; - buildInputs = [ env ]; + buildInputs = [ env dependencies ]; } From e38592731628a4bda13ef46deb7c2407dcde2672 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 2 Jul 2016 21:33:42 +0200 Subject: [PATCH 003/239] Add dependencies in .travis.yml Add also kalakris-cmake as source for apt --- .travis.yml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 94325312..8b2752fa 100644 --- a/.travis.yml +++ b/.travis.yml @@ -60,9 +60,14 @@ script: addons: apt: packages: + - cmake - libcurl4-openssl-dev - - libelf-dev - libdw-dev + - libelf-dev + - libzzip-dev + - tree + sources: + - kalakris-cmake after_success: - | pushd .imag-documentation && From 07a3a3226532514a1d05b06404b67ed3fa43c64c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 15 May 2016 00:21:26 +0200 Subject: [PATCH 004/239] Add basic module setup --- libimagstorestdhook/src/lib.rs | 1 + libimagstorestdhook/src/vcs/git/config.rs | 0 libimagstorestdhook/src/vcs/git/create.rs | 0 libimagstorestdhook/src/vcs/git/delete.rs | 0 libimagstorestdhook/src/vcs/git/error.rs | 80 +++++++++++++++++++++ libimagstorestdhook/src/vcs/git/mod.rs | 9 +++ libimagstorestdhook/src/vcs/git/result.rs | 5 ++ libimagstorestdhook/src/vcs/git/retrieve.rs | 0 libimagstorestdhook/src/vcs/git/update.rs | 0 libimagstorestdhook/src/vcs/git/util.rs | 12 ++++ libimagstorestdhook/src/vcs/mod.rs | 1 + 11 files changed, 108 insertions(+) create mode 100644 libimagstorestdhook/src/vcs/git/config.rs create mode 100644 libimagstorestdhook/src/vcs/git/create.rs create mode 100644 libimagstorestdhook/src/vcs/git/delete.rs create mode 100644 libimagstorestdhook/src/vcs/git/error.rs create mode 100644 libimagstorestdhook/src/vcs/git/mod.rs create mode 100644 libimagstorestdhook/src/vcs/git/result.rs create mode 100644 libimagstorestdhook/src/vcs/git/retrieve.rs create mode 100644 libimagstorestdhook/src/vcs/git/update.rs create mode 100644 libimagstorestdhook/src/vcs/git/util.rs create mode 100644 libimagstorestdhook/src/vcs/mod.rs diff --git a/libimagstorestdhook/src/lib.rs b/libimagstorestdhook/src/lib.rs index 2eee0156..a760d97a 100644 --- a/libimagstorestdhook/src/lib.rs +++ b/libimagstorestdhook/src/lib.rs @@ -26,4 +26,5 @@ extern crate libimagentrylink; pub mod debug; pub mod flock; pub mod linkverify; +pub mod vcs; diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs new file mode 100644 index 00000000..e69de29b diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs new file mode 100644 index 00000000..e69de29b diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs new file mode 100644 index 00000000..e69de29b diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs new file mode 100644 index 00000000..ca8d7937 --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -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>, +} + +impl GitHookError { + + /** + * Build a new GitHookError from an GitHookErrorKind, optionally with cause + */ + pub fn new(errtype: GitHookErrorKind, cause: Option>) + -> 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) + } + +} + diff --git a/libimagstorestdhook/src/vcs/git/mod.rs b/libimagstorestdhook/src/vcs/git/mod.rs new file mode 100644 index 00000000..1f068f4b --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/mod.rs @@ -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; + diff --git a/libimagstorestdhook/src/vcs/git/result.rs b/libimagstorestdhook/src/vcs/git/result.rs new file mode 100644 index 00000000..249fd4da --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/result.rs @@ -0,0 +1,5 @@ +use std::result::Result as RResult; + +use vcs::git::error::GitHookError; + +pub type Result = RResult; diff --git a/libimagstorestdhook/src/vcs/git/retrieve.rs b/libimagstorestdhook/src/vcs/git/retrieve.rs new file mode 100644 index 00000000..e69de29b diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs new file mode 100644 index 00000000..e69de29b diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs new file mode 100644 index 00000000..6e4382fe --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -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() +} + diff --git a/libimagstorestdhook/src/vcs/mod.rs b/libimagstorestdhook/src/vcs/mod.rs new file mode 100644 index 00000000..c2bf1c3e --- /dev/null +++ b/libimagstorestdhook/src/vcs/mod.rs @@ -0,0 +1 @@ +pub mod git; From 8f8568a03ae9fff82e1147552cc03f4b737c30f4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 15 May 2016 00:34:51 +0200 Subject: [PATCH 005/239] Add error module setup --- libimagstorestdhook/src/vcs/git/error.rs | 85 ++---------------------- 1 file changed, 7 insertions(+), 78 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index ca8d7937..fea5b793 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -1,80 +1,9 @@ -use std::error::Error; -use std::fmt::Error as FmtError; -use std::clone::Clone; -use std::fmt::{Display, Formatter}; +generate_error_module!( + generate_error_types!(GitHookError, GitHookErrorKind, + MkRepo => "Repository creation error" + ); +); -/** - * 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>, -} - -impl GitHookError { - - /** - * Build a new GitHookError from an GitHookErrorKind, optionally with cause - */ - pub fn new(errtype: GitHookErrorKind, cause: Option>) - -> 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) - } - -} +pub use self::error::GitHookError; +pub use self::error::GitHookErrorKind; From 24e747029cec3773752490c5896cb5b9eec9dd19 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 15 May 2016 00:35:09 +0200 Subject: [PATCH 006/239] Implement util::mkrepo() --- libimagstorestdhook/src/vcs/git/util.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index 6e4382fe..e94df0a3 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -2,8 +2,20 @@ //! //! Contains primitives to create a repository within the store path +use git2::Repository; + +use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::error::MapErrInto; + pub fn mkrepo(store: &Store) -> Result<()> { - unimplemented!() + let mut opts = RepositoryInitOptions::new(); + opts.bare(false); + opts.no_reinit(true); + opts.mkdir(false); + opts.external_template(false); + Repository::init_opts(store.path(), &opts) + .map(|_| ()) + .map_err_into(GHEK::MkRepo) } pub fn hasrepo(store: &Store) -> bool { From d03b13be1083a167c2e4bd9ae809db04031e3c5b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 15 May 2016 00:47:26 +0200 Subject: [PATCH 007/239] Add enum to represent store action --- libimagstorestdhook/src/vcs/git/action.rs | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 libimagstorestdhook/src/vcs/git/action.rs diff --git a/libimagstorestdhook/src/vcs/git/action.rs b/libimagstorestdhook/src/vcs/git/action.rs new file mode 100644 index 00000000..45cbf0da --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/action.rs @@ -0,0 +1,8 @@ +pub enum StoreAction { + Create, + Retrieve, + Update, + Delete, + + // "Read" doesn't matter, as we do not use git on read actions, only when altering content. +} From 61c3519d452d9f6787cb6ad3d444b0eb8bb09769 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 15 Jul 2016 22:29:28 +0200 Subject: [PATCH 008/239] Impl Debug, Clone, Display for StoreAction --- libimagstorestdhook/src/vcs/git/action.rs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/action.rs b/libimagstorestdhook/src/vcs/git/action.rs index 45cbf0da..26caf5a0 100644 --- a/libimagstorestdhook/src/vcs/git/action.rs +++ b/libimagstorestdhook/src/vcs/git/action.rs @@ -1,8 +1,24 @@ +use std::fmt::{Display, Formatter, Error}; + +#[derive(Clone, Debug)] pub enum StoreAction { Create, Retrieve, Update, Delete, - - // "Read" doesn't matter, as we do not use git on read actions, only when altering content. } + +impl Display for StoreAction { + + fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> { + write!(fmt, "StoreAction: {}", + match *self { + StoreAction::Create => "create", + StoreAction::Retrieve => "retrieve", + StoreAction::Update => "update", + StoreAction::Delete => "delete", + }) + } + +} + From 7f02f818da766144e64c4a5083763c8d45a05698 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 15 May 2016 00:47:43 +0200 Subject: [PATCH 009/239] Add (unimplemented) config helper functions --- libimagstorestdhook/src/vcs/git/config.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index e69de29b..0269782b 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -0,0 +1,11 @@ +pub fn commit_interactive(config: &Value) -> bool { + unimplemented!() +} + +pub fn commit_message(config: &Value, action: StoreAction) -> Option { + if commit_interactive(config) { + unimplemented!() + } else { + unimplemented!() + } +} From da0c4cf06b685abf70b4ac5f78c87aeb7217105f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 11:49:19 +0200 Subject: [PATCH 010/239] Add missing imports --- libimagstorestdhook/src/vcs/git/config.rs | 4 ++++ libimagstorestdhook/src/vcs/git/error.rs | 1 + libimagstorestdhook/src/vcs/git/mod.rs | 1 + libimagstorestdhook/src/vcs/git/util.rs | 4 ++++ 4 files changed, 10 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 0269782b..839a57d6 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -1,3 +1,7 @@ +use toml::Value; + +use vcs::git::action::StoreAction; + pub fn commit_interactive(config: &Value) -> bool { unimplemented!() } diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index fea5b793..f0851b1d 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -6,4 +6,5 @@ generate_error_module!( pub use self::error::GitHookError; pub use self::error::GitHookErrorKind; +pub use self::error::MapErrInto; diff --git a/libimagstorestdhook/src/vcs/git/mod.rs b/libimagstorestdhook/src/vcs/git/mod.rs index 1f068f4b..8eb16f34 100644 --- a/libimagstorestdhook/src/vcs/git/mod.rs +++ b/libimagstorestdhook/src/vcs/git/mod.rs @@ -1,3 +1,4 @@ +mod action; mod config; pub mod create; pub mod delete; diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index e94df0a3..e57e6acc 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -3,9 +3,13 @@ //! Contains primitives to create a repository within the store path use git2::Repository; +use git2::RepositoryInitOptions; + +use libimagstore::store::Store; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; +use vcs::git::result::Result; pub fn mkrepo(store: &Store) -> Result<()> { let mut opts = RepositoryInitOptions::new(); From 1f6a983a51da906616d4dbc2d78b84b5e7da00a7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 15 May 2016 00:47:56 +0200 Subject: [PATCH 011/239] Add boilerplate for create hook --- libimagstorestdhook/src/vcs/git/create.rs | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index e69de29b..8f239f12 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -0,0 +1,54 @@ +use toml::Value; + +use libimagstore::storeid::StoreId; +use libimagstore::hook::Hook; +use libimagstore::hook::result::HookResult; +use libimagstore::hook::position::HookPosition; +use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; +use libimagstore::hook::accessor::StoreIdAccessor; + +#[derive(Debug)] +pub struct CreateHook { + position: HookPosition, + config: Option, +} + +impl CreateHook { + + pub fn new(p: HookPosition) -> CreateHook { + CreateHook { + position: p, + config: None, + } + } + +} + +impl Hook for CreateHook { + + fn name(&self) -> &'static str { + "stdhook_git_create" + } + + fn set_config(&mut self, config: &Value) { + self.config = Some(config.clone()); + } + +} + +impl HookDataAccessorProvider for CreateHook { + + fn accessor(&self) -> HookDataAccessor { + HookDataAccessor::StoreIdAccess(self) + } +} + +impl StoreIdAccessor for CreateHook { + + fn access(&self, id: &StoreId) -> HookResult<()> { + debug!("[GIT CREATE HOOK]: {:?}", id); + Ok(()) + } + +} + From bcd728a9301c60dfadbee40dc6fa2bcefc00a34c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 15 Jul 2016 22:41:30 +0200 Subject: [PATCH 012/239] Add boilerplate for delete hook --- libimagstorestdhook/src/vcs/git/delete.rs | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index e69de29b..38f3bac1 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -0,0 +1,54 @@ +use toml::Value; + +use libimagstore::storeid::StoreId; +use libimagstore::hook::Hook; +use libimagstore::hook::result::HookResult; +use libimagstore::hook::position::HookPosition; +use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; +use libimagstore::hook::accessor::StoreIdAccessor; + +#[derive(Debug)] +pub struct DeleteHook { + position: HookPosition, + config: Option, +} + +impl DeleteHook { + + pub fn new(p: HookPosition) -> DeleteHook { + DeleteHook { + position: p, + config: None, + } + } + +} + +impl Hook for DeleteHook { + + fn name(&self) -> &'static str { + "stdhook_git_delete" + } + + fn set_config(&mut self, config: &Value) { + self.config = Some(config.clone()); + } + +} + +impl HookDataAccessorProvider for DeleteHook { + + fn accessor(&self) -> HookDataAccessor { + HookDataAccessor::StoreIdAccess(self) + } +} + +impl StoreIdAccessor for DeleteHook { + + fn access(&self, id: &StoreId) -> HookResult<()> { + debug!("[GIT DELETE HOOK]: {:?}", id); + Ok(()) + } + +} + From 9ef0271893cd88e302e80e3c28d0bb305df9bb96 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 15 Jul 2016 22:41:59 +0200 Subject: [PATCH 013/239] Add boilerplate for retrieve hook --- libimagstorestdhook/src/vcs/git/retrieve.rs | 54 +++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/retrieve.rs b/libimagstorestdhook/src/vcs/git/retrieve.rs index e69de29b..e65840f7 100644 --- a/libimagstorestdhook/src/vcs/git/retrieve.rs +++ b/libimagstorestdhook/src/vcs/git/retrieve.rs @@ -0,0 +1,54 @@ +use toml::Value; + +use libimagstore::storeid::StoreId; +use libimagstore::hook::Hook; +use libimagstore::hook::result::HookResult; +use libimagstore::hook::position::HookPosition; +use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; +use libimagstore::hook::accessor::StoreIdAccessor; + +#[derive(Debug)] +pub struct RetrieveHook { + position: HookPosition, + config: Option, +} + +impl RetrieveHook { + + pub fn new(p: HookPosition) -> RetrieveHook { + RetrieveHook { + position: p, + config: None, + } + } + +} + +impl Hook for RetrieveHook { + + fn name(&self) -> &'static str { + "stdhook_git_retrieve" + } + + fn set_config(&mut self, config: &Value) { + self.config = Some(config.clone()); + } + +} + +impl HookDataAccessorProvider for RetrieveHook { + + fn accessor(&self) -> HookDataAccessor { + HookDataAccessor::StoreIdAccess(self) + } +} + +impl StoreIdAccessor for RetrieveHook { + + fn access(&self, id: &StoreId) -> HookResult<()> { + debug!("[GIT RETRIEVE HOOK]: {:?}", id); + Ok(()) + } + +} + From 6ecd97956f435a152300b334615396a7d4694f62 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 15 Jul 2016 22:42:10 +0200 Subject: [PATCH 014/239] Add boilerplate for update hook --- libimagstorestdhook/src/vcs/git/update.rs | 54 +++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index e69de29b..67bb85d4 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -0,0 +1,54 @@ +use toml::Value; + +use libimagstore::storeid::StoreId; +use libimagstore::hook::Hook; +use libimagstore::hook::result::HookResult; +use libimagstore::hook::position::HookPosition; +use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; +use libimagstore::hook::accessor::StoreIdAccessor; + +#[derive(Debug)] +pub struct UpdateHook { + position: HookPosition, + config: Option, +} + +impl UpdateHook { + + pub fn new(p: HookPosition) -> UpdateHook { + UpdateHook { + position: p, + config: None, + } + } + +} + +impl Hook for UpdateHook { + + fn name(&self) -> &'static str { + "stdhook_git_update" + } + + fn set_config(&mut self, config: &Value) { + self.config = Some(config.clone()); + } + +} + +impl HookDataAccessorProvider for UpdateHook { + + fn accessor(&self) -> HookDataAccessor { + HookDataAccessor::StoreIdAccess(self) + } +} + +impl StoreIdAccessor for UpdateHook { + + fn access(&self, id: &StoreId) -> HookResult<()> { + debug!("[GIT UPDATE HOOK]: {:?}", id); + Ok(()) + } + +} + From 010109a3c3103ae888a2db388c1a998ea4bea1fd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 15 Jul 2016 23:08:37 +0200 Subject: [PATCH 015/239] Disable lints --- libimagstorestdhook/src/lib.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libimagstorestdhook/src/lib.rs b/libimagstorestdhook/src/lib.rs index a760d97a..70c6bbc7 100644 --- a/libimagstorestdhook/src/lib.rs +++ b/libimagstorestdhook/src/lib.rs @@ -1,18 +1,18 @@ -#![deny( - dead_code, - non_camel_case_types, - non_snake_case, - path_statements, - trivial_numeric_casts, - unstable_features, - unused_allocation, - unused_import_braces, - unused_imports, - unused_must_use, - unused_mut, - unused_qualifications, - while_true, -)] +// #![deny( +// dead_code, +// non_camel_case_types, +// non_snake_case, +// path_statements, +// trivial_numeric_casts, +// unstable_features, +// unused_allocation, +// unused_import_braces, +// unused_imports, +// unused_must_use, +// unused_mut, +// unused_qualifications, +// while_true, +// )] #[macro_use] extern crate log; extern crate toml; From 2562b705b811596f4eb033787cf108bbd8619411 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 15 Jul 2016 23:24:28 +0200 Subject: [PATCH 016/239] Add git hooks in the runtime setup code --- libimagrt/src/runtime.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index e847631d..697bfcae 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -43,6 +43,10 @@ impl<'a> Runtime<'a> { use libimagstore::hook::Hook; use libimagstore::error::StoreErrorKind; use libimagstorestdhook::debug::DebugHook; + use libimagstorestdhook::vcs::git::create::CreateHook as GitCreateHook; + use libimagstorestdhook::vcs::git::delete::DeleteHook as GitDeleteHook; + use libimagstorestdhook::vcs::git::retrieve::RetrieveHook as GitRetrieveHook; + use libimagstorestdhook::vcs::git::update::UpdateHook as GitUpdateHook; use libimagerror::trace::trace_error; use libimagerror::trace::trace_error_dbg; use libimagerror::into::IntoError; @@ -119,6 +123,11 @@ impl<'a> Runtime<'a> { (Box::new(DebugHook::new(HP::PostUpdate)) , "debug", HP::PostUpdate), (Box::new(DebugHook::new(HP::PreDelete)) , "debug", HP::PreDelete), (Box::new(DebugHook::new(HP::PostDelete)) , "debug", HP::PostDelete), + + (Box::new(GitCreateHook::new(HP::PostCreate)) , "vcs", HP::PostCreate), + (Box::new(GitDeleteHook::new(HP::PreDelete)) , "vcs", HP::PreDelete), + (Box::new(GitRetrieveHook::new(HP::PostRetrieve)) , "vcs", HP::PostRetrieve), + (Box::new(GitUpdateHook::new(HP::PostUpdate)) , "vcs", HP::PostUpdate), ]; // If hook registration fails, trace the error and warn, but continue. From 7776e95345a17c14abeca9f4023cc9930428c427 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 15 Jul 2016 23:25:09 +0200 Subject: [PATCH 017/239] Add vcs (git) hook settings in imagrc example --- imagrc.toml | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/imagrc.toml b/imagrc.toml index 82a2dae3..af8145a5 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -12,25 +12,41 @@ implicit-create = false # store, so these hooks should be chosen carefully. store-unload-hook-aspects = [ "debug" ] -pre-create-hook-aspects = [ "debug" ] -post-create-hook-aspects = [ "debug" ] +pre-create-hook-aspects = [ "debug", "vcs" ] +post-create-hook-aspects = [ "debug", "vcs" ] pre-move-hook-aspects = [ "debug" ] post-move-hook-aspects = [ "debug" ] -pre-retrieve-hook-aspects = [ "debug" ] -post-retrieve-hook-aspects = [ "debug" ] +pre-retrieve-hook-aspects = [ "debug", "vcs" ] +post-retrieve-hook-aspects = [ "debug", "vcs" ] -pre-update-hook-aspects = [ "debug" ] -post-update-hook-aspects = [ "debug" ] +pre-update-hook-aspects = [ "debug", "vcs" ] +post-update-hook-aspects = [ "debug", "vcs" ] -pre-delete-hook-aspects = [ "debug" ] -post-delete-hook-aspects = [ "debug" ] +pre-delete-hook-aspects = [ "debug", "vcs" ] +post-delete-hook-aspects = [ "debug", "vcs" ] [store.aspects.debug] parallel = false mutable_hooks = true +[store.aspects.vcs] +parallel = false +mutable_hooks = false + [store.hooks.stdhook_debug] aspect = "debug" +[store.hooks.stdhook_git_create] +aspect = "vcs" + +[store.hooks.stdhook_git_delete] +aspect = "vcs" + +[store.hooks.stdhook_git_retrieve] +aspect = "vcs" + +[store.hooks.stdhook_git_update] +aspect = "vcs" + From f0404d91e83626a169cf109e12ca395a7bf8bbef Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 15:59:08 +0200 Subject: [PATCH 018/239] Pass store path to git hooks, so we can initialize properly --- libimagrt/src/runtime.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index 697bfcae..df4ba3b9 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -111,7 +111,7 @@ impl<'a> Runtime<'a> { write!(stderr(), "Store-config: {:?}\n", store_config).ok(); } - Store::new(storepath, store_config).map(|mut store| { + Store::new(storepath.clone(), store_config).map(|mut store| { // If we are debugging, generate hooks for all positions if is_debugging { let hooks : Vec<(Box, &str, HP)> = vec![ @@ -124,10 +124,10 @@ impl<'a> Runtime<'a> { (Box::new(DebugHook::new(HP::PreDelete)) , "debug", HP::PreDelete), (Box::new(DebugHook::new(HP::PostDelete)) , "debug", HP::PostDelete), - (Box::new(GitCreateHook::new(HP::PostCreate)) , "vcs", HP::PostCreate), - (Box::new(GitDeleteHook::new(HP::PreDelete)) , "vcs", HP::PreDelete), - (Box::new(GitRetrieveHook::new(HP::PostRetrieve)) , "vcs", HP::PostRetrieve), - (Box::new(GitUpdateHook::new(HP::PostUpdate)) , "vcs", HP::PostUpdate), + (Box::new(GitCreateHook::new(&storepath, HP::PostCreate)) , "vcs", HP::PostCreate), + (Box::new(GitDeleteHook::new(&storepath, HP::PreDelete)) , "vcs", HP::PreDelete), + (Box::new(GitRetrieveHook::new(&storepath, HP::PostRetrieve)), "vcs", HP::PostRetrieve), + (Box::new(GitUpdateHook::new(&storepath, HP::PostUpdate)) , "vcs", HP::PostUpdate), ]; // If hook registration fails, trace the error and warn, but continue. From 397c38d8058cdeafc4c397d6d697dcac60c6ae6d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 15:59:53 +0200 Subject: [PATCH 019/239] Add store path member for create hook --- libimagstorestdhook/src/vcs/git/create.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 8f239f12..8b78daa4 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + use toml::Value; use libimagstore::storeid::StoreId; @@ -8,15 +10,18 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; #[derive(Debug)] -pub struct CreateHook { +pub struct CreateHook<'a> { + storepath: &'a PathBuf, + position: HookPosition, config: Option, } -impl CreateHook { +impl<'a> CreateHook<'a> { - pub fn new(p: HookPosition) -> CreateHook { + pub fn new(storepath: &'a PathBuf, p: HookPosition) -> CreateHook<'a> { CreateHook { + storepath: storepath, position: p, config: None, } @@ -24,7 +29,7 @@ impl CreateHook { } -impl Hook for CreateHook { +impl<'a> Hook for CreateHook<'a> { fn name(&self) -> &'static str { "stdhook_git_create" @@ -36,14 +41,14 @@ impl Hook for CreateHook { } -impl HookDataAccessorProvider for CreateHook { +impl<'a> HookDataAccessorProvider for CreateHook<'a> { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl StoreIdAccessor for CreateHook { +impl<'a> StoreIdAccessor for CreateHook<'a> { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT CREATE HOOK]: {:?}", id); From f4a71831c9475a5529afc2a2af773e636a084a81 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 15:59:53 +0200 Subject: [PATCH 020/239] Add store path member for delete hook --- libimagstorestdhook/src/vcs/git/delete.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index 38f3bac1..fd476b21 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + use toml::Value; use libimagstore::storeid::StoreId; @@ -8,15 +10,18 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; #[derive(Debug)] -pub struct DeleteHook { +pub struct DeleteHook<'a> { + storepath: &'a PathBuf, + position: HookPosition, config: Option, } -impl DeleteHook { +impl<'a> DeleteHook<'a> { - pub fn new(p: HookPosition) -> DeleteHook { + pub fn new(storepath: &'a PathBuf, p: HookPosition) -> DeleteHook<'a> { DeleteHook { + storepath: storepath, position: p, config: None, } @@ -24,7 +29,7 @@ impl DeleteHook { } -impl Hook for DeleteHook { +impl<'a> Hook for DeleteHook<'a> { fn name(&self) -> &'static str { "stdhook_git_delete" @@ -36,14 +41,14 @@ impl Hook for DeleteHook { } -impl HookDataAccessorProvider for DeleteHook { +impl<'a> HookDataAccessorProvider for DeleteHook<'a> { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl StoreIdAccessor for DeleteHook { +impl<'a> StoreIdAccessor for DeleteHook<'a> { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT DELETE HOOK]: {:?}", id); From 0e765cd5b69a504ed71d538c85cf696783f5454c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 15:59:53 +0200 Subject: [PATCH 021/239] Add store path member for retrieve hook --- libimagstorestdhook/src/vcs/git/retrieve.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/retrieve.rs b/libimagstorestdhook/src/vcs/git/retrieve.rs index e65840f7..ae7b61e6 100644 --- a/libimagstorestdhook/src/vcs/git/retrieve.rs +++ b/libimagstorestdhook/src/vcs/git/retrieve.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + use toml::Value; use libimagstore::storeid::StoreId; @@ -8,15 +10,18 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; #[derive(Debug)] -pub struct RetrieveHook { +pub struct RetrieveHook<'a> { + storepath: &'a PathBuf, + position: HookPosition, config: Option, } -impl RetrieveHook { +impl<'a> RetrieveHook<'a> { - pub fn new(p: HookPosition) -> RetrieveHook { + pub fn new(storepath: &'a PathBuf, p: HookPosition) -> RetrieveHook<'a> { RetrieveHook { + storepath: storepath, position: p, config: None, } @@ -24,7 +29,7 @@ impl RetrieveHook { } -impl Hook for RetrieveHook { +impl<'a> Hook for RetrieveHook<'a> { fn name(&self) -> &'static str { "stdhook_git_retrieve" @@ -36,14 +41,14 @@ impl Hook for RetrieveHook { } -impl HookDataAccessorProvider for RetrieveHook { +impl<'a> HookDataAccessorProvider for RetrieveHook<'a> { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl StoreIdAccessor for RetrieveHook { +impl<'a> StoreIdAccessor for RetrieveHook<'a> { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT RETRIEVE HOOK]: {:?}", id); From a8ea51460c0bb3910b3a5d91bba24329ffe74f6c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 15:59:53 +0200 Subject: [PATCH 022/239] Add store path member for update hook --- libimagstorestdhook/src/vcs/git/update.rs | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 67bb85d4..f551d7f6 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -1,3 +1,5 @@ +use std::path::PathBuf; + use toml::Value; use libimagstore::storeid::StoreId; @@ -8,15 +10,18 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; #[derive(Debug)] -pub struct UpdateHook { +pub struct UpdateHook<'a> { + storepath: &'a PathBuf, + position: HookPosition, config: Option, } -impl UpdateHook { +impl<'a> UpdateHook<'a> { - pub fn new(p: HookPosition) -> UpdateHook { + pub fn new(storepath: &'a PathBuf, p: HookPosition) -> UpdateHook<'a> { UpdateHook { + storepath: storepath, position: p, config: None, } @@ -24,7 +29,7 @@ impl UpdateHook { } -impl Hook for UpdateHook { +impl<'a> Hook for UpdateHook<'a> { fn name(&self) -> &'static str { "stdhook_git_update" @@ -36,14 +41,14 @@ impl Hook for UpdateHook { } -impl HookDataAccessorProvider for UpdateHook { +impl<'a> HookDataAccessorProvider for UpdateHook<'a> { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl StoreIdAccessor for UpdateHook { +impl<'a> StoreIdAccessor for UpdateHook<'a> { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT UPDATE HOOK]: {:?}", id); From e19121f43abb4a8c9abbbf62e71ff6fc49705c3b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 16:26:01 +0200 Subject: [PATCH 023/239] Impl Debug for CreateHook --- libimagstorestdhook/src/vcs/git/create.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 8b78daa4..88817434 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -1,4 +1,5 @@ use std::path::PathBuf; +use std::fmt::{Debug, Formatter, Error as FmtError}; use toml::Value; @@ -9,7 +10,6 @@ use libimagstore::hook::position::HookPosition; use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; -#[derive(Debug)] pub struct CreateHook<'a> { storepath: &'a PathBuf, @@ -29,6 +29,17 @@ impl<'a> CreateHook<'a> { } +impl<'a> Debug for CreateHook<'a> { + + fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> { + write!(fmt, "CreateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}", + self.storepath, + (if self.repository.is_some() { "Some(_)" } else { "None" }), + self.position, + self.config) + } +} + impl<'a> Hook for CreateHook<'a> { fn name(&self) -> &'static str { From af089952c8cc4c0eb8c873a92fe654a11d0da043 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 16:26:16 +0200 Subject: [PATCH 024/239] Add Repository instantiation --- libimagstorestdhook/src/vcs/git/create.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 88817434..887c2f0c 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -2,6 +2,7 @@ use std::path::PathBuf; use std::fmt::{Debug, Formatter, Error as FmtError}; use toml::Value; +use git2::{Repository, Error as Git2Error}; use libimagstore::storeid::StoreId; use libimagstore::hook::Hook; @@ -9,10 +10,13 @@ use libimagstore::hook::result::HookResult; use libimagstore::hook::position::HookPosition; use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; +use libimagerror::trace::trace_error; pub struct CreateHook<'a> { storepath: &'a PathBuf, + repository: Option, + position: HookPosition, config: Option, } @@ -20,8 +24,16 @@ pub struct CreateHook<'a> { impl<'a> CreateHook<'a> { pub fn new(storepath: &'a PathBuf, p: HookPosition) -> CreateHook<'a> { + let r = match Repository::open(storepath) { + Ok(r) => Some(r), + Err(e) => { + trace_error(&e); + None + }, + }; CreateHook { storepath: storepath, + repository: r, position: p, config: None, } From 4436a294e2cd5c1dda195d0ea05c31e351a45cf0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 17:28:49 +0200 Subject: [PATCH 025/239] Add helper to check config whether to abort the hook failing This helper can be used to check the configuration of the hook whether it should abort if the repository cannot be opened. --- libimagstorestdhook/src/vcs/git/config.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 839a57d6..726f4ddc 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -13,3 +13,22 @@ pub fn commit_message(config: &Value, action: StoreAction) -> Option { unimplemented!() } } + +pub fn abort_on_repo_init_err(cfg: Option<&Value>) -> bool { + cfg.map(|cfg| { + match cfg.lookup("abort_on_repo_init_failure") { + Some(&Value::Boolean(b)) => b, + Some(_) => { + warn!("Configuration error, 'abort_on_repo_init_failure' must be a Boolean (true|false)."); + warn!("Assuming 'true' now."); + true + }, + None => { + debug!("No key `abort_on_repo_init_failure' - Assuming 'true'"); + true + }, + } + }) + .unwrap_or(false) +} + From f6897844020ba5723c73ad8baced2b05e1fc249d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 17:31:19 +0200 Subject: [PATCH 026/239] Add imagrc cfg, whether to abort hooks if repo init failed --- imagrc.toml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/imagrc.toml b/imagrc.toml index af8145a5..37023ac3 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -41,12 +41,32 @@ aspect = "debug" [store.hooks.stdhook_git_create] aspect = "vcs" -[store.hooks.stdhook_git_delete] -aspect = "vcs" +# Fail if the repository cannot be opened. If this is set to `false`, the error +# will be printed, but will not abort the store operation. `true` will print the +# error and abort the store action. +abort_on_repo_init_failure = true [store.hooks.stdhook_git_retrieve] aspect = "vcs" +# Fail if the repository cannot be opened. If this is set to `false`, the error +# will be printed, but will not abort the store operation. `true` will print the +# error and abort the store action. +abort_on_repo_init_failure = true + +[store.hooks.stdhook_git_delete] +aspect = "vcs" + +# Fail if the repository cannot be opened. If this is set to `false`, the error +# will be printed, but will not abort the store operation. `true` will print the +# error and abort the store action. +abort_on_repo_init_failure = true + [store.hooks.stdhook_git_update] aspect = "vcs" +# Fail if the repository cannot be opened. If this is set to `false`, the error +# will be printed, but will not abort the store operation. `true` will print the +# error and abort the store action. +abort_on_repo_init_failure = true + From c09f0b302f851aa49a3b5d70ddf78ad5c55fa625 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 17:56:34 +0200 Subject: [PATCH 027/239] Add error kinds for configuration errors --- libimagstorestdhook/src/vcs/git/error.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index f0851b1d..7c9838d1 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -1,5 +1,7 @@ generate_error_module!( generate_error_types!(GitHookError, GitHookErrorKind, + ConfigError => "Configuration Error", + ConfigTypeError => "Configuration value type wrong", MkRepo => "Repository creation error" ); ); From c972b5706d65a3a16b8d22fb154b42a1ff908496 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 17:58:00 +0200 Subject: [PATCH 028/239] Add helper to get the branch which must be checked out before any action takes place --- libimagstorestdhook/src/vcs/git/config.rs | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 726f4ddc..995eb0a6 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -1,5 +1,11 @@ use toml::Value; +use libimagerror::into::IntoError; + +use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::error::MapErrInto; +use vcs::git::result::Result; + use vcs::git::action::StoreAction; pub fn commit_interactive(config: &Value) -> bool { @@ -32,3 +38,23 @@ pub fn abort_on_repo_init_err(cfg: Option<&Value>) -> bool { .unwrap_or(false) } +pub fn ensure_branch(cfg: Option<&Value>) -> Result> { + match cfg { + Some(cfg) => { + match cfg.lookup("ensure_branch") { + Some(&Value::String(ref s)) => Ok(Some(s.clone())), + Some(_) => { + warn!("Configuration error, 'ensure_branch' must be a String."); + Err(GHEK::ConfigTypeError.into_error()) + .map_err_into(GHEK::ConfigTypeError) + }, + None => { + debug!("No key `ensure_branch'"); + Ok(None) + }, + } + }, + None => Ok(None), + } +} + From 7ed44cc1b8fd04a6a9f2af2183c15227e1cbac8e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 17:58:18 +0200 Subject: [PATCH 029/239] Add example settings for ensure_branch --- imagrc.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/imagrc.toml b/imagrc.toml index 37023ac3..ed6570e2 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -46,6 +46,9 @@ aspect = "vcs" # error and abort the store action. abort_on_repo_init_failure = true +# Ensure to be on this branche before doing anything. +ensure_branch = "master" + [store.hooks.stdhook_git_retrieve] aspect = "vcs" @@ -54,6 +57,9 @@ aspect = "vcs" # error and abort the store action. abort_on_repo_init_failure = true +# Ensure to be on this branche before doing anything. +ensure_branch = "master" + [store.hooks.stdhook_git_delete] aspect = "vcs" @@ -62,6 +68,9 @@ aspect = "vcs" # error and abort the store action. abort_on_repo_init_failure = true +# Ensure to be on this branche before doing anything. +ensure_branch = "master" + [store.hooks.stdhook_git_update] aspect = "vcs" @@ -70,3 +79,6 @@ aspect = "vcs" # error and abort the store action. abort_on_repo_init_failure = true +# Ensure to be on this branche before doing anything. +ensure_branch = "master" + From a356a96a992430ae37e1df8570ea1a43dfeee3fa Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 18:00:42 +0200 Subject: [PATCH 030/239] Add helper to check whether to try to checkout the ensure_branch branch --- libimagstorestdhook/src/vcs/git/config.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 995eb0a6..c4de04c4 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -58,3 +58,21 @@ pub fn ensure_branch(cfg: Option<&Value>) -> Result> { } } +pub fn do_checkout_ensure_branch(cfg: Option<&Value>) -> bool { + cfg.map(|cfg| { + match cfg.lookup("try_checkout_ensure_branch") { + Some(&Value::Boolean(b)) => b, + Some(_) => { + warn!("Configuration error, 'try_checkout_ensure_branch' must be a Boolean (true|false)."); + warn!("Assuming 'true' now."); + true + }, + None => { + debug!("No key `try_checkout_ensure_branch' - Assuming 'true'"); + true + }, + } + }) + .unwrap_or(false) +} + From 0892aa36f890f5d044c242c4d0fbd9cd9daaf599 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 18:01:02 +0200 Subject: [PATCH 031/239] Add example setting for trying to checkout the ensure_branch branch --- imagrc.toml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/imagrc.toml b/imagrc.toml index ed6570e2..29b93e22 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -49,6 +49,9 @@ abort_on_repo_init_failure = true # Ensure to be on this branche before doing anything. ensure_branch = "master" +# Try to checkout the ensure_branch if it isn't checked out +try_checkout_ensure_branch = true + [store.hooks.stdhook_git_retrieve] aspect = "vcs" @@ -60,6 +63,9 @@ abort_on_repo_init_failure = true # Ensure to be on this branche before doing anything. ensure_branch = "master" +# Try to checkout the ensure_branch if it isn't checked out +try_checkout_ensure_branch = true + [store.hooks.stdhook_git_delete] aspect = "vcs" @@ -71,6 +77,9 @@ abort_on_repo_init_failure = true # Ensure to be on this branche before doing anything. ensure_branch = "master" +# Try to checkout the ensure_branch if it isn't checked out +try_checkout_ensure_branch = true + [store.hooks.stdhook_git_update] aspect = "vcs" @@ -82,3 +91,6 @@ abort_on_repo_init_failure = true # Ensure to be on this branche before doing anything. ensure_branch = "master" +# Try to checkout the ensure_branch if it isn't checked out +try_checkout_ensure_branch = true + From 554ec2ca5c41164d1f6e848444b711d7afab412a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 18:03:56 +0200 Subject: [PATCH 032/239] Refactor: Use helper function internally --- libimagstorestdhook/src/vcs/git/config.rs | 32 ++++++++--------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index c4de04c4..ce732032 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -21,21 +21,7 @@ pub fn commit_message(config: &Value, action: StoreAction) -> Option { } pub fn abort_on_repo_init_err(cfg: Option<&Value>) -> bool { - cfg.map(|cfg| { - match cfg.lookup("abort_on_repo_init_failure") { - Some(&Value::Boolean(b)) => b, - Some(_) => { - warn!("Configuration error, 'abort_on_repo_init_failure' must be a Boolean (true|false)."); - warn!("Assuming 'true' now."); - true - }, - None => { - debug!("No key `abort_on_repo_init_failure' - Assuming 'true'"); - true - }, - } - }) - .unwrap_or(false) + get_bool_cfg(cfg, "abort_on_repo_init_failure", true, true) } pub fn ensure_branch(cfg: Option<&Value>) -> Result> { @@ -59,20 +45,24 @@ pub fn ensure_branch(cfg: Option<&Value>) -> Result> { } pub fn do_checkout_ensure_branch(cfg: Option<&Value>) -> bool { + get_bool_cfg(cfg, "try_checkout_ensure_branch", true, true) +} + +fn get_bool_cfg(cfg: Option<&Value>, name: &str, on_fail: bool, on_unavail: bool) -> bool { cfg.map(|cfg| { - match cfg.lookup("try_checkout_ensure_branch") { + match cfg.lookup(name) { Some(&Value::Boolean(b)) => b, Some(_) => { - warn!("Configuration error, 'try_checkout_ensure_branch' must be a Boolean (true|false)."); + warn!("Configuration error, '{}' must be a Boolean (true|false).", name); warn!("Assuming 'true' now."); - true + on_fail }, None => { - debug!("No key `try_checkout_ensure_branch' - Assuming 'true'"); - true + debug!("No key '{}' - Assuming 'true'", name); + on_fail }, } }) - .unwrap_or(false) + .unwrap_or(on_unavail) } From 189ebb2aeaefc66399d9f6efea04d65234ab8a09 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 18:36:29 +0200 Subject: [PATCH 033/239] Add error kinds for repository interaction errors --- libimagstorestdhook/src/vcs/git/error.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index 7c9838d1..b136b71e 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -2,7 +2,20 @@ generate_error_module!( generate_error_types!(GitHookError, GitHookErrorKind, ConfigError => "Configuration Error", ConfigTypeError => "Configuration value type wrong", - MkRepo => "Repository creation error" + RepositoryError => "Error while interacting with git repository", + RepositoryBranchError => "Error while interacting with git branch(es)", + RepositoryBranchNameFetchingError => "Error while fetching branch name", + RepositorySignatureFetchingError => "Error while fetching Authors/Committers signature", + RepositoryIndexFetchingError => "Error while fetching Repository Index", + RepositoryPathAddingError => "Error while adding Path to Index", + RepositoryTreeWritingError => "Error while writing repository tree", + RepositoryTreeFindingError => "Error while finding repository tree", + RepositoryCommitFindingError => "Error while finding commit", + RepositoryCommittingError => "Error while committing", + HeadFetchError => "Error while getting HEAD", + NotOnBranch => "No Branch is checked out", + MkRepo => "Repository creation error", + MkSignature => "Error while building Signature object" ); ); From 830d170518294698c928d1ee7c1838f5b9b5a26d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 21 Jul 2016 17:54:44 +0200 Subject: [PATCH 034/239] Add GitHookError::inside_if() --- libimagstorestdhook/src/vcs/git/error.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index b136b71e..5d0e404c 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -1,3 +1,7 @@ +use libimagstore::hook::error::HookError as HE; +use libimagstore::hook::error::HookErrorKind as HEK; +use libimagstore::hook::result::HookResult; + generate_error_module!( generate_error_types!(GitHookError, GitHookErrorKind, ConfigError => "Configuration Error", @@ -19,6 +23,14 @@ generate_error_module!( ); ); +impl GitHookError { + + pub fn inside_of(self, h: HEK) -> HookResult { + Err(HE::new(h, Some(Box::new(self)))) + } + +} + pub use self::error::GitHookError; pub use self::error::GitHookErrorKind; pub use self::error::MapErrInto; From 4de051e1bbbe130f5eb0f3d547b75013161daefb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 16 Jul 2016 17:32:06 +0200 Subject: [PATCH 035/239] Start impl of StoreIdAccessor for CreateHook --- libimagstorestdhook/src/vcs/git/create.rs | 74 ++++++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 887c2f0c..0534b870 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -1,16 +1,27 @@ use std::path::PathBuf; use std::fmt::{Debug, Formatter, Error as FmtError}; +use std::result::Result as RResult; use toml::Value; -use git2::{Repository, Error as Git2Error}; +use git2::{Reference as GitReference, Repository, Error as Git2Error}; use libimagstore::storeid::StoreId; use libimagstore::hook::Hook; +use libimagstore::hook::error::HookError as HE; +use libimagstore::hook::error::HookErrorKind as HEK; +use libimagstore::hook::error::CustomData as HECD; use libimagstore::hook::result::HookResult; use libimagstore::hook::position::HookPosition; use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; use libimagerror::trace::trace_error; +use libimagerror::into::IntoError; + +use vcs::git::result::Result; +use vcs::git::error::MapErrInto; +use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::error::GitHookError as GHE; +use vcs::git::config::ensure_branch; pub struct CreateHook<'a> { storepath: &'a PathBuf, @@ -39,11 +50,26 @@ impl<'a> CreateHook<'a> { } } + fn repository(&self) -> HookResult<&Repository> { + use vcs::git::config::abort_on_repo_init_err; + + match self.repository.as_ref() { + Some(r) => Ok(r), + None => { + debug!("Repository isn't initialized... creating error object now"); + let he = GHEK::MkRepo.into_error(); + let he = HE::new(HEK::HookExecutionError, Some(Box::new(he))); + let custom = HECD::default().aborting(abort_on_repo_init_err(self.config.as_ref())); + return Err(he.with_custom_data(custom)); + } + } + } + } impl<'a> Debug for CreateHook<'a> { - fn fmt(&self, fmt: &mut Formatter) -> Result<(), FmtError> { + fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { write!(fmt, "CreateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}", self.storepath, (if self.repository.is_some() { "Some(_)" } else { "None" }), @@ -75,8 +101,52 @@ impl<'a> StoreIdAccessor for CreateHook<'a> { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT CREATE HOOK]: {:?}", id); + let repository = try!(self.repository()); + let head = try!(repository.head().map_err_into(GHEK::HeadFetchError) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(Box::new(e)))); + + if head.is_branch() { + return GHEK::NotOnBranch.into_error().inside_of(HEK::HookExecutionError) + } + + try!(checkout_branch(self.config.as_ref(), &head) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(Box::new(e)))); + + // Now to the create() hook action + + unimplemented!() + Ok(()) } } +fn checkout_branch(config: Option<&Value>, head: &GitReference) -> Result<()> { + // Check out appropriate branch ... or fail + match ensure_branch(config) { + Ok(Some(s)) => { + match head.name().map(|name| name == s) { + Some(b) => { + if b { + debug!("Branch already checked out."); + Ok(()) + } else { + debug!("Branch not checked out."); + unimplemented!() + } + }, + + None => Err(GHEK::RepositoryBranchNameFetchingError.into_error()) + .map_err_into(GHEK::RepositoryBranchError) + .map_err_into(GHEK::RepositoryError), + } + }, + Ok(None) => { + debug!("No branch to checkout"); + Ok(()) + }, + + Err(e) => Err(e).map_err_into(GHEK::RepositoryError), + } +} + From 3b138d2add360a8a68af8a1588283e7da0ab6f4a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 14:38:36 +0200 Subject: [PATCH 036/239] Add Runtime object for git hooks --- libimagstorestdhook/src/vcs/git/mod.rs | 1 + libimagstorestdhook/src/vcs/git/runtime.rs | 69 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 libimagstorestdhook/src/vcs/git/runtime.rs diff --git a/libimagstorestdhook/src/vcs/git/mod.rs b/libimagstorestdhook/src/vcs/git/mod.rs index 8eb16f34..ca9f5c61 100644 --- a/libimagstorestdhook/src/vcs/git/mod.rs +++ b/libimagstorestdhook/src/vcs/git/mod.rs @@ -4,6 +4,7 @@ pub mod create; pub mod delete; mod error; mod result; +mod runtime; pub mod retrieve; pub mod update; pub mod util; diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs new file mode 100644 index 00000000..44255613 --- /dev/null +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -0,0 +1,69 @@ +use std::path::PathBuf; + +use git2::{Repository, Signature}; + +use libimagerror::into::IntoError; +use libimagerror::trace::trace_error; + +use vcs::git::result::Result; +use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::config::{author_name, author_mail, committer_name, committer_mail}; + +struct Person<'a> { + pub name: &'a str, + pub mail: &'a str, +} + +impl<'a> Person<'a> { + fn new(name: &'a str, mail: &'a str) -> Person<'a> { + Person { name: name, mail: mail } + } +} + +struct Runtime<'a> { + pub repository: Option, + pub author: Option>, + pub committer: Option>, +} + +impl<'a> Runtime<'a> { + + pub fn new(storepath: &PathBuf) -> Runtime<'a> { + Runtime { + repository: match Repository::open(storepath) { + Ok(r) => Some(r), + Err(e) => { + trace_error(&e); + None + }, + }, + + author: None, + committer: None, + } + } + + pub fn configure(&mut self, config: &Value) -> Result<()> { + author_name(cfg) + .and_then(|n| author_email(cfg).map(|m| Person::new(n, m))) + .and_then(|author| { + committer_name(cfg) + .and_then(|n| committer_email(cfg).map(|m| (author, Person::new(n, m)))) + }) + .map(|(author, committer)| { + self.author = Some(author); + self.committer = Some(committer); + }) + } + + pub fn new_committer_sig(&self) -> Option> { + self.committer + .as_ref() + .map(|c| { + Signature::now(c.name, c.mail) + .map_err(|e| GHEK::MkSignature.into_error_with_cause(Box::new(e))) + }) + } + +} + From 3c80632d4d0b3954abc378e3ce60178754ef25a0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 14:38:55 +0200 Subject: [PATCH 037/239] Add error kind for runtime info setup errors --- libimagstorestdhook/src/vcs/git/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index 5d0e404c..788aebd8 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -6,6 +6,7 @@ generate_error_module!( generate_error_types!(GitHookError, GitHookErrorKind, ConfigError => "Configuration Error", ConfigTypeError => "Configuration value type wrong", + RuntimeInformationSetupError => "Couldn't setup runtime information for git hook", RepositoryError => "Error while interacting with git repository", RepositoryBranchError => "Error while interacting with git branch(es)", RepositoryBranchNameFetchingError => "Error while fetching branch name", From edd37b0e88836ea07dcda66c8ecee13cc5f51a0f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 14:39:18 +0200 Subject: [PATCH 038/239] Add stubs for getting information from the config --- libimagstorestdhook/src/vcs/git/config.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index ce732032..5bae6887 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -8,6 +8,22 @@ use vcs::git::result::Result; use vcs::git::action::StoreAction; +pub fn author_name(config: &Value) -> Result<&str> { + unimplemented!() +} + +pub fn author_mail(config: &Value) -> Result<&str> { + unimplemented!() +} + +pub fn committer_name(config: &Value) -> Result<&str> { + unimplemented!() +} + +pub fn committer_mail(config: &Value) -> Result<&str> { + unimplemented!() +} + pub fn commit_interactive(config: &Value) -> bool { unimplemented!() } From 57fbeb54e75c9e1bb589ec7f087212aa2df49ac1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 14:47:52 +0200 Subject: [PATCH 039/239] Add Runtime::repository() --- libimagstorestdhook/src/vcs/git/runtime.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 44255613..663c1d2e 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -65,5 +65,9 @@ impl<'a> Runtime<'a> { }) } + pub fn repository(&self) -> Result<&Repository> { + self.repository.as_ref().ok_or(GHEK::MkRepo.into_error()) + } + } From 464a9c4e4eef32abe8733aec56ff58392eebc421 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 14:49:25 +0200 Subject: [PATCH 040/239] Make Runtime fields nonpublic --- libimagstorestdhook/src/vcs/git/runtime.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 663c1d2e..80160db6 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -21,9 +21,9 @@ impl<'a> Person<'a> { } struct Runtime<'a> { - pub repository: Option, - pub author: Option>, - pub committer: Option>, + repository: Option, + author: Option>, + committer: Option>, } impl<'a> Runtime<'a> { From e13722accbeab7c57a3be6873ab65d73868d1694 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 14:49:39 +0200 Subject: [PATCH 041/239] Make Runtime pub --- libimagstorestdhook/src/vcs/git/runtime.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 80160db6..52588864 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -20,7 +20,7 @@ impl<'a> Person<'a> { } } -struct Runtime<'a> { +pub struct Runtime<'a> { repository: Option, author: Option>, committer: Option>, From e5503116adc500d00f8746ff2824d70391171e25 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 14:53:56 +0200 Subject: [PATCH 042/239] Add Runtime::ensure_configured_branch_is_checked_out --- libimagstorestdhook/src/vcs/git/runtime.rs | 57 ++++++++++++++++++++-- 1 file changed, 54 insertions(+), 3 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 52588864..63fcc96d 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -1,12 +1,15 @@ use std::path::PathBuf; use git2::{Repository, Signature}; +use toml::Value; use libimagerror::into::IntoError; use libimagerror::trace::trace_error; +use libimagstore::hook::error::CustomData; +use libimagstore::hook::error::HookErrorKind as HEK; use vcs::git::result::Result; -use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::error::{MapErrInto, GitHookErrorKind as GHEK}; use vcs::git::config::{author_name, author_mail, committer_name, committer_mail}; struct Person<'a> { @@ -45,10 +48,10 @@ impl<'a> Runtime<'a> { pub fn configure(&mut self, config: &Value) -> Result<()> { author_name(cfg) - .and_then(|n| author_email(cfg).map(|m| Person::new(n, m))) + .and_then(|n| author_mail(cfg).map(|m| Person::new(n, m))) .and_then(|author| { committer_name(cfg) - .and_then(|n| committer_email(cfg).map(|m| (author, Person::new(n, m)))) + .and_then(|n| committer_mail(cfg).map(|m| (author, Person::new(n, m)))) }) .map(|(author, committer)| { self.author = Some(author); @@ -69,5 +72,53 @@ impl<'a> Runtime<'a> { self.repository.as_ref().ok_or(GHEK::MkRepo.into_error()) } + pub fn ensure_cfg_branch_is_checked_out(&self) -> HookResult<()> { + use vcs::git::config::ensure_branch; + + let head = try!(self + .repository() + .and_then(|r| { + r.head().map_err_into(GHEK::HeadFetchError) + }) + .map_err(Box::new) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e))); + + // TODO: Fail if not on branch? hmmh... I'm not sure + if head.is_branch() { + return Err(GHEK::NotOnBranch.into_error()) + .map_err(Box::new) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)); + } + + // Check out appropriate branch ... or fail + match ensure_branch(self.config.as_ref()) { + Ok(Some(s)) => { + match head.name().map(|name| name == s) { + Some(b) => { + if b { + debug!("Branch already checked out."); + Ok(()) + } else { + debug!("Branch not checked out."); + unimplemented!() + } + }, + + None => Err(GHEK::RepositoryBranchNameFetchingError.into_error()) + .map_err_into(GHEK::RepositoryBranchError) + .map_err_into(GHEK::RepositoryError), + } + }, + Ok(None) => { + debug!("No branch to checkout"); + Ok(()) + }, + + Err(e) => Err(e).map_err_into(GHEK::RepositoryError), + } + .map_err(Box::new) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)) + } + } From 2ef530b46222b5e13766cf8f75340729728b74e6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 15:04:51 +0200 Subject: [PATCH 043/239] Add error kind if config is not available --- libimagstorestdhook/src/vcs/git/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index 788aebd8..4b4daf96 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -5,6 +5,7 @@ use libimagstore::hook::result::HookResult; generate_error_module!( generate_error_types!(GitHookError, GitHookErrorKind, ConfigError => "Configuration Error", + NoConfigError => "No Configuration", ConfigTypeError => "Configuration value type wrong", RuntimeInformationSetupError => "Couldn't setup runtime information for git hook", RepositoryError => "Error while interacting with git repository", From 9ed13f265d45cbb864c050ec0bb3a2aaeabc028a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 15:06:02 +0200 Subject: [PATCH 044/239] Move config to Runtime --- libimagstorestdhook/src/vcs/git/create.rs | 8 +++--- libimagstorestdhook/src/vcs/git/runtime.rs | 32 ++++++++++++++++++---- 2 files changed, 30 insertions(+), 10 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 0534b870..cb0e2355 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -29,7 +29,6 @@ pub struct CreateHook<'a> { repository: Option, position: HookPosition, - config: Option, } impl<'a> CreateHook<'a> { @@ -46,7 +45,6 @@ impl<'a> CreateHook<'a> { storepath: storepath, repository: r, position: p, - config: None, } } @@ -74,7 +72,7 @@ impl<'a> Debug for CreateHook<'a> { self.storepath, (if self.repository.is_some() { "Some(_)" } else { "None" }), self.position, - self.config) + self.runtime.has_config()) } } @@ -85,7 +83,9 @@ impl<'a> Hook for CreateHook<'a> { } fn set_config(&mut self, config: &Value) { - self.config = Some(config.clone()); + if let Err(e) = self.runtime.set_config(config) { + trace_error(&e); + } } } diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 63fcc96d..055be89e 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -27,6 +27,8 @@ pub struct Runtime<'a> { repository: Option, author: Option>, committer: Option>, + + config: Option, } impl<'a> Runtime<'a> { @@ -43,20 +45,38 @@ impl<'a> Runtime<'a> { author: None, committer: None, + config: None, } } - pub fn configure(&mut self, config: &Value) -> Result<()> { - author_name(cfg) - .and_then(|n| author_mail(cfg).map(|m| Person::new(n, m))) + pub fn set_config(&mut self, cfg: &Value) -> Result<()> { + let config = cfg.clone(); + let res = author_name(&config) + .and_then(|n| author_mail(&config).map(|m| Person::new(n, m))) .and_then(|author| { - committer_name(cfg) - .and_then(|n| committer_mail(cfg).map(|m| (author, Person::new(n, m)))) + committer_name(&config) + .and_then(|n| committer_mail(&config).map(|m| (author, Person::new(n, m)))) }) .map(|(author, committer)| { self.author = Some(author); self.committer = Some(committer); - }) + }); + self.config = Some(config); + res + } + + pub fn has_config(&self) -> bool { + self.config.is_some() + } + + pub fn config_value_or_err(&self) -> HookResult<&Value> { + self.config + .as_ref() + .ok_or(GHEK::NoConfigError.into_error()) + .map_err_into(GHEK::ConfigError) + .map_err(Box::new) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)) + .map_err(|mut e| e.with_custom_data(CustomData::default().aborting(false))) } pub fn new_committer_sig(&self) -> Option> { From d498ed75d959a6d32aba320e9cbb6cbc23175abd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 15:06:58 +0200 Subject: [PATCH 045/239] Use Runtime object rather than own Repository object --- libimagstorestdhook/src/vcs/git/create.rs | 75 +++-------------------- 1 file changed, 10 insertions(+), 65 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index cb0e2355..71922720 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -21,12 +21,12 @@ use vcs::git::result::Result; use vcs::git::error::MapErrInto; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::GitHookError as GHE; -use vcs::git::config::ensure_branch; +use vcs::git::runtime::Runtime; pub struct CreateHook<'a> { storepath: &'a PathBuf, - repository: Option, + runtime: Runtime<'a>, position: HookPosition, } @@ -34,35 +34,13 @@ pub struct CreateHook<'a> { impl<'a> CreateHook<'a> { pub fn new(storepath: &'a PathBuf, p: HookPosition) -> CreateHook<'a> { - let r = match Repository::open(storepath) { - Ok(r) => Some(r), - Err(e) => { - trace_error(&e); - None - }, - }; CreateHook { storepath: storepath, - repository: r, + runtime: Runtime::new(storepath), position: p, } } - fn repository(&self) -> HookResult<&Repository> { - use vcs::git::config::abort_on_repo_init_err; - - match self.repository.as_ref() { - Some(r) => Ok(r), - None => { - debug!("Repository isn't initialized... creating error object now"); - let he = GHEK::MkRepo.into_error(); - let he = HE::new(HEK::HookExecutionError, Some(Box::new(he))); - let custom = HECD::default().aborting(abort_on_repo_init_err(self.config.as_ref())); - return Err(he.with_custom_data(custom)); - } - } - } - } impl<'a> Debug for CreateHook<'a> { @@ -70,7 +48,7 @@ impl<'a> Debug for CreateHook<'a> { fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { write!(fmt, "CreateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}", self.storepath, - (if self.repository.is_some() { "Some(_)" } else { "None" }), + (if self.runtime.has_repository() { "Some(_)" } else { "None" }), self.position, self.runtime.has_config()) } @@ -101,16 +79,12 @@ impl<'a> StoreIdAccessor for CreateHook<'a> { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT CREATE HOOK]: {:?}", id); - let repository = try!(self.repository()); - let head = try!(repository.head().map_err_into(GHEK::HeadFetchError) - .map_err(|e| HEK::HookExecutionError.into_error_with_cause(Box::new(e)))); - - if head.is_branch() { - return GHEK::NotOnBranch.into_error().inside_of(HEK::HookExecutionError) - } - - try!(checkout_branch(self.config.as_ref(), &head) - .map_err(|e| HEK::HookExecutionError.into_error_with_cause(Box::new(e)))); + try!(self + .runtime + .ensure_cfg_branch_is_checked_out() + .map_err(Box::new) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e))); + let repository = try!(self.runtime.repository()); // Now to the create() hook action @@ -121,32 +95,3 @@ impl<'a> StoreIdAccessor for CreateHook<'a> { } -fn checkout_branch(config: Option<&Value>, head: &GitReference) -> Result<()> { - // Check out appropriate branch ... or fail - match ensure_branch(config) { - Ok(Some(s)) => { - match head.name().map(|name| name == s) { - Some(b) => { - if b { - debug!("Branch already checked out."); - Ok(()) - } else { - debug!("Branch not checked out."); - unimplemented!() - } - }, - - None => Err(GHEK::RepositoryBranchNameFetchingError.into_error()) - .map_err_into(GHEK::RepositoryBranchError) - .map_err_into(GHEK::RepositoryError), - } - }, - Ok(None) => { - debug!("No branch to checkout"); - Ok(()) - }, - - Err(e) => Err(e).map_err_into(GHEK::RepositoryError), - } -} - From e0a390d8407d892220818236aad0c2a56aea1e2d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 15:15:31 +0200 Subject: [PATCH 046/239] Add Runtime::has_repository() --- libimagstorestdhook/src/vcs/git/runtime.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 055be89e..f32551e8 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -65,6 +65,10 @@ impl<'a> Runtime<'a> { res } + pub fn has_repository(&self) -> bool { + self.repository.is_some() + } + pub fn has_config(&self) -> bool { self.config.is_some() } From 9d9338d0e425f8b1117434351db826426b509065 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 15:38:43 +0200 Subject: [PATCH 047/239] Add Runtime::new_committer_sig() --- libimagstorestdhook/src/vcs/git/runtime.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index f32551e8..39fa2d8f 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -92,6 +92,15 @@ impl<'a> Runtime<'a> { }) } + pub fn new_committer_sig(&self) -> Option> { + self.committer + .as_ref() + .map(|c| { + Signature::now(c.name, c.mail) + .map_err(|e| GHEK::MkSignature.into_error_with_cause(Box::new(e))) + }) + } + pub fn repository(&self) -> Result<&Repository> { self.repository.as_ref().ok_or(GHEK::MkRepo.into_error()) } From 21c6945a4679d8db17b26ab563f6ed0af5b93ac4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 15:40:00 +0200 Subject: [PATCH 048/239] Add missing import of HookResult --- libimagstorestdhook/src/vcs/git/runtime.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 39fa2d8f..36cbda02 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -7,6 +7,7 @@ use libimagerror::into::IntoError; use libimagerror::trace::trace_error; use libimagstore::hook::error::CustomData; use libimagstore::hook::error::HookErrorKind as HEK; +use libimagstore::hook::result::HookResult; use vcs::git::result::Result; use vcs::git::error::{MapErrInto, GitHookErrorKind as GHEK}; From 81c0a9e170893e747f4780fa0ea47bf0725e42b6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 22 Jul 2016 15:49:57 +0200 Subject: [PATCH 049/239] Impl From for HookError --- libimagstorestdhook/src/vcs/git/error.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index 4b4daf96..0af7b0ab 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -33,6 +33,14 @@ impl GitHookError { } +impl From for HE { + + fn from(he: GitHookError) -> HE { + HE::new(HEK::HookExecutionError, Some(Box::new(he))) + } + +} + pub use self::error::GitHookError; pub use self::error::GitHookErrorKind; pub use self::error::MapErrInto; From d59b139f237fd76d3aa3a477ac5e7d7d990fb4da Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 26 Jul 2016 14:36:31 +0200 Subject: [PATCH 050/239] Revert "Add Runtime::new_committer_sig()" This reverts commit 883a3392279baddc3a1305874e7c7e92e1d485dc. --- libimagstorestdhook/src/vcs/git/runtime.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 36cbda02..674870dd 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -84,24 +84,6 @@ impl<'a> Runtime<'a> { .map_err(|mut e| e.with_custom_data(CustomData::default().aborting(false))) } - pub fn new_committer_sig(&self) -> Option> { - self.committer - .as_ref() - .map(|c| { - Signature::now(c.name, c.mail) - .map_err(|e| GHEK::MkSignature.into_error_with_cause(Box::new(e))) - }) - } - - pub fn new_committer_sig(&self) -> Option> { - self.committer - .as_ref() - .map(|c| { - Signature::now(c.name, c.mail) - .map_err(|e| GHEK::MkSignature.into_error_with_cause(Box::new(e))) - }) - } - pub fn repository(&self) -> Result<&Repository> { self.repository.as_ref().ok_or(GHEK::MkRepo.into_error()) } From 2dbad3f23242f68ae23b5cb1ac7c9f657f868980 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 26 Jul 2016 14:37:29 +0200 Subject: [PATCH 051/239] Revert "Add stubs for getting information from the config" This reverts commit 8f7f89ae10325a2f7f2e64378c3342c14780563b. --- libimagstorestdhook/src/vcs/git/config.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 5bae6887..ce732032 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -8,22 +8,6 @@ use vcs::git::result::Result; use vcs::git::action::StoreAction; -pub fn author_name(config: &Value) -> Result<&str> { - unimplemented!() -} - -pub fn author_mail(config: &Value) -> Result<&str> { - unimplemented!() -} - -pub fn committer_name(config: &Value) -> Result<&str> { - unimplemented!() -} - -pub fn committer_mail(config: &Value) -> Result<&str> { - unimplemented!() -} - pub fn commit_interactive(config: &Value) -> bool { unimplemented!() } From 068c7318579c0a515aa7a063fd3253aa75b404e7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 26 Jul 2016 14:40:46 +0200 Subject: [PATCH 052/239] Remove author/committer fetching, the git2 crate can do this --- libimagstorestdhook/src/vcs/git/runtime.rs | 32 ++-------------------- 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 674870dd..49771d7e 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -11,24 +11,9 @@ use libimagstore::hook::result::HookResult; use vcs::git::result::Result; use vcs::git::error::{MapErrInto, GitHookErrorKind as GHEK}; -use vcs::git::config::{author_name, author_mail, committer_name, committer_mail}; - -struct Person<'a> { - pub name: &'a str, - pub mail: &'a str, -} - -impl<'a> Person<'a> { - fn new(name: &'a str, mail: &'a str) -> Person<'a> { - Person { name: name, mail: mail } - } -} pub struct Runtime<'a> { repository: Option, - author: Option>, - committer: Option>, - config: Option, } @@ -44,26 +29,13 @@ impl<'a> Runtime<'a> { }, }, - author: None, - committer: None, config: None, } } pub fn set_config(&mut self, cfg: &Value) -> Result<()> { - let config = cfg.clone(); - let res = author_name(&config) - .and_then(|n| author_mail(&config).map(|m| Person::new(n, m))) - .and_then(|author| { - committer_name(&config) - .and_then(|n| committer_mail(&config).map(|m| (author, Person::new(n, m)))) - }) - .map(|(author, committer)| { - self.author = Some(author); - self.committer = Some(committer); - }); - self.config = Some(config); - res + self.config = Some(cfg.clone()); + Ok(()) } pub fn has_repository(&self) -> bool { From ba1b4682d7302e9ed73a8573ac5a634d8995c57d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 26 Jul 2016 14:41:40 +0200 Subject: [PATCH 053/239] Remove lifetimes from Runtime struct --- libimagstorestdhook/src/vcs/git/create.rs | 2 +- libimagstorestdhook/src/vcs/git/runtime.rs | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 71922720..16d16f04 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -26,7 +26,7 @@ use vcs::git::runtime::Runtime; pub struct CreateHook<'a> { storepath: &'a PathBuf, - runtime: Runtime<'a>, + runtime: Runtime, position: HookPosition, } diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 49771d7e..c996f67b 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -12,14 +12,14 @@ use libimagstore::hook::result::HookResult; use vcs::git::result::Result; use vcs::git::error::{MapErrInto, GitHookErrorKind as GHEK}; -pub struct Runtime<'a> { +pub struct Runtime { repository: Option, config: Option, } -impl<'a> Runtime<'a> { +impl Runtime { - pub fn new(storepath: &PathBuf) -> Runtime<'a> { + pub fn new(storepath: &PathBuf) -> Runtime { Runtime { repository: match Repository::open(storepath) { Ok(r) => Some(r), From 5615ad12dfbf28d83abc7029d190c011fd167dab Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 27 Jul 2016 13:06:12 +0200 Subject: [PATCH 054/239] Let the commit_message() helper always return a proper commit msg --- libimagstorestdhook/src/vcs/git/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index ce732032..b3cec006 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -12,7 +12,7 @@ pub fn commit_interactive(config: &Value) -> bool { unimplemented!() } -pub fn commit_message(config: &Value, action: StoreAction) -> Option { +pub fn commit_message(config: &Value, action: StoreAction) -> String { if commit_interactive(config) { unimplemented!() } else { From 204ebc884ce3a76a6385dc072da881122a2f9a57 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 27 Jul 2016 13:07:40 +0200 Subject: [PATCH 055/239] Runtime::repository() should return HookResult --- libimagstorestdhook/src/vcs/git/runtime.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index c996f67b..b9a7d92b 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -56,8 +56,12 @@ impl Runtime { .map_err(|mut e| e.with_custom_data(CustomData::default().aborting(false))) } - pub fn repository(&self) -> Result<&Repository> { - self.repository.as_ref().ok_or(GHEK::MkRepo.into_error()) + pub fn repository(&self) -> HookResult<&Repository> { + self.repository + .as_ref() + .ok_or(GHEK::MkRepo.into_error()) + .map_err(Box::new) + .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)) } pub fn ensure_cfg_branch_is_checked_out(&self) -> HookResult<()> { From e5a066ed0b97abdf8467fb9a0be42b595b35c222 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 27 Jul 2016 13:10:54 +0200 Subject: [PATCH 056/239] Add error kind and impl From for HE --- libimagstorestdhook/src/vcs/git/error.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index 0af7b0ab..f7ce2cb6 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -1,3 +1,5 @@ +use git2::Error as Git2Error; + use libimagstore::hook::error::HookError as HE; use libimagstore::hook::error::HookErrorKind as HEK; use libimagstore::hook::result::HookResult; @@ -8,6 +10,7 @@ generate_error_module!( NoConfigError => "No Configuration", ConfigTypeError => "Configuration value type wrong", RuntimeInformationSetupError => "Couldn't setup runtime information for git hook", + RepositoryBackendError => "Error in the git library", RepositoryError => "Error while interacting with git repository", RepositoryBranchError => "Error while interacting with git branch(es)", RepositoryBranchNameFetchingError => "Error while fetching branch name", @@ -41,6 +44,14 @@ impl From for HE { } +impl From for GitHookError { + + fn from(ge: Git2Error) -> GitHookError { + GitHookError::new(GitHookErrorKind::RepositoryBackendError, Some(Box::new(ge))) + } + +} + pub use self::error::GitHookError; pub use self::error::GitHookErrorKind; pub use self::error::MapErrInto; From 989c1790be21dcd2201397fc2c0b619922b58f1c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 27 Jul 2016 13:17:30 +0200 Subject: [PATCH 057/239] Simplify error creating code snippet, as we have From<> now implemented --- libimagstorestdhook/src/vcs/git/runtime.rs | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index b9a7d92b..6c783a66 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -70,16 +70,12 @@ impl Runtime { let head = try!(self .repository() .and_then(|r| { - r.head().map_err_into(GHEK::HeadFetchError) - }) - .map_err(Box::new) - .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e))); + r.head().map_err_into(GHEK::HeadFetchError).map_err(|e| e.into()) + })); // TODO: Fail if not on branch? hmmh... I'm not sure if head.is_branch() { - return Err(GHEK::NotOnBranch.into_error()) - .map_err(Box::new) - .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)); + return Err(GHEK::NotOnBranch.into_error().into()); } // Check out appropriate branch ... or fail From 6714f4e3c7217bbc496386af19facb0db4b8efb7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 27 Jul 2016 13:38:04 +0200 Subject: [PATCH 058/239] Implement CreateHook::access() --- libimagstorestdhook/src/vcs/git/create.rs | 68 +++++++++++++++++++++-- 1 file changed, 62 insertions(+), 6 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 16d16f04..7fb39739 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -78,19 +78,75 @@ impl<'a> HookDataAccessorProvider for CreateHook<'a> { impl<'a> StoreIdAccessor for CreateHook<'a> { fn access(&self, id: &StoreId) -> HookResult<()> { + use vcs::git::action::StoreAction; + use vcs::git::config::commit_message; + debug!("[GIT CREATE HOOK]: {:?}", id); try!(self .runtime .ensure_cfg_branch_is_checked_out() .map_err(Box::new) .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e))); - let repository = try!(self.runtime.repository()); - // Now to the create() hook action - - unimplemented!() - - Ok(()) + self.runtime + .config_value_or_err() + .and_then(|cfg| { + self.runtime + .repository() + .map(|r| (r, cfg)) + .map_err_into(GHEK::RepositoryError) + .map_err(|e| e.into()) + }) + .and_then(|(repo, cfg)| { + repo.signature() + .map(|s| (repo, cfg, s)) + .map_err_into(GHEK::RepositorySignatureFetchingError) + .map_err_into(GHEK::RepositoryError) + .map_err(|e| e.into()) + }) + .and_then(|(repo, cfg, sig)| { + repo.index() + .map(|idx| (repo, cfg, sig, idx)) + .map_err_into(GHEK::RepositoryIndexFetchingError) + .map_err_into(GHEK::RepositoryError) + .map_err(|e| e.into()) + }) + .and_then(|(repo, cfg, sig, mut idx)| { + idx.add_path(id) + .map(|_| (repo, cfg, sig, idx)) + .map_err_into(GHEK::RepositoryPathAddingError) + .map_err_into(GHEK::RepositoryError) + .map_err(|e| e.into()) + }) + .and_then(|(repo, cfg, sig, mut idx)| { + idx.write_tree() + .map(|oid| (repo, cfg, sig, idx, oid)) + .map_err_into(GHEK::RepositoryTreeWritingError) + .map_err_into(GHEK::RepositoryError) + .map_err(|e| e.into()) + }) + .and_then(|(repo, cfg, sig, idx, oid)| { + repo.find_tree(oid) + .map(|tree| (repo, cfg, sig, idx, oid, tree)) + .map_err_into(GHEK::RepositoryTreeFindingError) + .map_err_into(GHEK::RepositoryError) + .map_err(|e| e.into()) + }) + .and_then(|(repo, cfg, sig, idx, oid, tree)| { + let cmtmsg = commit_message(cfg, StoreAction::Create); + repo.find_commit(oid) + .map(|cmt| (repo, sig, tree, cmt, cmtmsg)) + .map_err_into(GHEK::RepositoryCommitFindingError) + .map_err_into(GHEK::RepositoryError) + .map_err(|e| e.into()) + }) + .and_then(|(repo, sig, tree, cmt, commitmsg)| { + repo.commit(Some("HEAD"), &sig, &sig, &commitmsg[..], &tree, &[&cmt]) + .map_err_into(GHEK::RepositoryCommittingError) + .map_err_into(GHEK::RepositoryError) + .map_err(|e| e.into()) + }) + .map(|_| ()) } } From 112646c002882d2d8607f7720593558cabc2fbd4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 10:00:28 +0200 Subject: [PATCH 059/239] Do not store reference to store path in the hook objects --- libimagstorestdhook/src/vcs/git/create.rs | 18 +++++++++--------- libimagstorestdhook/src/vcs/git/delete.rs | 14 +++++++------- libimagstorestdhook/src/vcs/git/retrieve.rs | 14 +++++++------- libimagstorestdhook/src/vcs/git/update.rs | 14 +++++++------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 7fb39739..43fd1c7a 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -23,27 +23,27 @@ use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::GitHookError as GHE; use vcs::git::runtime::Runtime; -pub struct CreateHook<'a> { - storepath: &'a PathBuf, +pub struct CreateHook { + storepath: PathBuf, runtime: Runtime, position: HookPosition, } -impl<'a> CreateHook<'a> { +impl CreateHook { - pub fn new(storepath: &'a PathBuf, p: HookPosition) -> CreateHook<'a> { + pub fn new(storepath: PathBuf, p: HookPosition) -> CreateHook { CreateHook { + runtime: Runtime::new(&storepath), storepath: storepath, - runtime: Runtime::new(storepath), position: p, } } } -impl<'a> Debug for CreateHook<'a> { +impl Debug for CreateHook { fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { write!(fmt, "CreateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}", @@ -54,7 +54,7 @@ impl<'a> Debug for CreateHook<'a> { } } -impl<'a> Hook for CreateHook<'a> { +impl Hook for CreateHook { fn name(&self) -> &'static str { "stdhook_git_create" @@ -68,14 +68,14 @@ impl<'a> Hook for CreateHook<'a> { } -impl<'a> HookDataAccessorProvider for CreateHook<'a> { +impl HookDataAccessorProvider for CreateHook { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl<'a> StoreIdAccessor for CreateHook<'a> { +impl StoreIdAccessor for CreateHook { fn access(&self, id: &StoreId) -> HookResult<()> { use vcs::git::action::StoreAction; diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index fd476b21..902e5096 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -10,16 +10,16 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; #[derive(Debug)] -pub struct DeleteHook<'a> { - storepath: &'a PathBuf, +pub struct DeleteHook { + storepath: PathBuf, position: HookPosition, config: Option, } -impl<'a> DeleteHook<'a> { +impl DeleteHook { - pub fn new(storepath: &'a PathBuf, p: HookPosition) -> DeleteHook<'a> { + pub fn new(storepath: PathBuf, p: HookPosition) -> DeleteHook { DeleteHook { storepath: storepath, position: p, @@ -29,7 +29,7 @@ impl<'a> DeleteHook<'a> { } -impl<'a> Hook for DeleteHook<'a> { +impl Hook for DeleteHook { fn name(&self) -> &'static str { "stdhook_git_delete" @@ -41,14 +41,14 @@ impl<'a> Hook for DeleteHook<'a> { } -impl<'a> HookDataAccessorProvider for DeleteHook<'a> { +impl HookDataAccessorProvider for DeleteHook { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl<'a> StoreIdAccessor for DeleteHook<'a> { +impl StoreIdAccessor for DeleteHook { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT DELETE HOOK]: {:?}", id); diff --git a/libimagstorestdhook/src/vcs/git/retrieve.rs b/libimagstorestdhook/src/vcs/git/retrieve.rs index ae7b61e6..ca034812 100644 --- a/libimagstorestdhook/src/vcs/git/retrieve.rs +++ b/libimagstorestdhook/src/vcs/git/retrieve.rs @@ -10,16 +10,16 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; #[derive(Debug)] -pub struct RetrieveHook<'a> { - storepath: &'a PathBuf, +pub struct RetrieveHook { + storepath: PathBuf, position: HookPosition, config: Option, } -impl<'a> RetrieveHook<'a> { +impl RetrieveHook { - pub fn new(storepath: &'a PathBuf, p: HookPosition) -> RetrieveHook<'a> { + pub fn new(storepath: PathBuf, p: HookPosition) -> RetrieveHook { RetrieveHook { storepath: storepath, position: p, @@ -29,7 +29,7 @@ impl<'a> RetrieveHook<'a> { } -impl<'a> Hook for RetrieveHook<'a> { +impl Hook for RetrieveHook { fn name(&self) -> &'static str { "stdhook_git_retrieve" @@ -41,14 +41,14 @@ impl<'a> Hook for RetrieveHook<'a> { } -impl<'a> HookDataAccessorProvider for RetrieveHook<'a> { +impl HookDataAccessorProvider for RetrieveHook { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl<'a> StoreIdAccessor for RetrieveHook<'a> { +impl StoreIdAccessor for RetrieveHook { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT RETRIEVE HOOK]: {:?}", id); diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index f551d7f6..4a5026d0 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -10,16 +10,16 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; #[derive(Debug)] -pub struct UpdateHook<'a> { - storepath: &'a PathBuf, +pub struct UpdateHook { + storepath: PathBuf, position: HookPosition, config: Option, } -impl<'a> UpdateHook<'a> { +impl UpdateHook { - pub fn new(storepath: &'a PathBuf, p: HookPosition) -> UpdateHook<'a> { + pub fn new(storepath: PathBuf, p: HookPosition) -> UpdateHook { UpdateHook { storepath: storepath, position: p, @@ -29,7 +29,7 @@ impl<'a> UpdateHook<'a> { } -impl<'a> Hook for UpdateHook<'a> { +impl Hook for UpdateHook { fn name(&self) -> &'static str { "stdhook_git_update" @@ -41,14 +41,14 @@ impl<'a> Hook for UpdateHook<'a> { } -impl<'a> HookDataAccessorProvider for UpdateHook<'a> { +impl HookDataAccessorProvider for UpdateHook { fn accessor(&self) -> HookDataAccessor { HookDataAccessor::StoreIdAccess(self) } } -impl<'a> StoreIdAccessor for UpdateHook<'a> { +impl StoreIdAccessor for UpdateHook { fn access(&self, id: &StoreId) -> HookResult<()> { debug!("[GIT UPDATE HOOK]: {:?}", id); From f23004a8ec96a1bbcedc7703a3418e39b9970d8c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 10:01:02 +0200 Subject: [PATCH 060/239] Make git-hook-registration not only when debugging --- libimagrt/src/runtime.rs | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index df4ba3b9..67d9950b 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -123,11 +123,6 @@ impl<'a> Runtime<'a> { (Box::new(DebugHook::new(HP::PostUpdate)) , "debug", HP::PostUpdate), (Box::new(DebugHook::new(HP::PreDelete)) , "debug", HP::PreDelete), (Box::new(DebugHook::new(HP::PostDelete)) , "debug", HP::PostDelete), - - (Box::new(GitCreateHook::new(&storepath, HP::PostCreate)) , "vcs", HP::PostCreate), - (Box::new(GitDeleteHook::new(&storepath, HP::PreDelete)) , "vcs", HP::PreDelete), - (Box::new(GitRetrieveHook::new(&storepath, HP::PostRetrieve)), "vcs", HP::PostRetrieve), - (Box::new(GitUpdateHook::new(&storepath, HP::PostUpdate)) , "vcs", HP::PostUpdate), ]; // If hook registration fails, trace the error and warn, but continue. @@ -143,6 +138,26 @@ impl<'a> Runtime<'a> { } } + let sp = storepath; + + let hooks : Vec<(Box, &str, HP)> = vec![ + (Box::new(GitCreateHook::new(sp.clone(), HP::PostCreate)) , "vcs", HP::PostCreate), + (Box::new(GitDeleteHook::new(sp.clone(), HP::PreDelete)) , "vcs", HP::PreDelete), + (Box::new(GitRetrieveHook::new(sp.clone(), HP::PostRetrieve)), "vcs", HP::PostRetrieve), + (Box::new(GitUpdateHook::new(sp, HP::PostUpdate)) , "vcs", HP::PostUpdate), + ]; + + for (hook, aspectname, position) in hooks { + if let Err(e) = store.register_hook(position, &String::from(aspectname), hook) { + if e.err_type() == StoreErrorKind::HookRegisterError { + trace_error_dbg(&e); + warn!("Registering debug hook with store failed"); + } else { + trace_error(&e); + }; + } + } + Runtime { cli_matches: matches, configuration: cfg, From d1fee32c7d474e896d376dd574e764de474ecdba Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 10:10:23 +0200 Subject: [PATCH 061/239] Just do not execute mutable hooks, but let pass the nonmutables --- libimagstore/src/hook/aspect.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libimagstore/src/hook/aspect.rs b/libimagstore/src/hook/aspect.rs index bd493122..9c888554 100644 --- a/libimagstore/src/hook/aspect.rs +++ b/libimagstore/src/hook/aspect.rs @@ -68,10 +68,6 @@ impl MutableHookDataAccessor for Aspect { fn access_mut(&self, fle: &mut FileLockEntry) -> HookResult<()> { debug!("Checking whether mutable hooks are allowed"); debug!("-> config = {:?}", self.cfg); - if !self.cfg.as_ref().map(|c| c.allow_mutable_hooks()).unwrap_or(false) { - debug!("Apparently mutable hooks are not allowed... failing now."); - return Err(HE::new(HEK::MutableHooksNotAllowed, None)); - } let accessors : Vec = self.hooks.iter().map(|h| h.accessor()).collect(); @@ -82,8 +78,15 @@ impl MutableHookDataAccessor for Aspect { accessors.iter().fold_defresult(|accessor| { let res = match accessor { &HDA::StoreIdAccess(ref accessor) => accessor.access(fle.get_location()), - &HDA::MutableAccess(ref accessor) => accessor.access_mut(fle), &HDA::NonMutableAccess(ref accessor) => accessor.access(fle), + &HDA::MutableAccess(ref accessor) => { + if !self.cfg.as_ref().map(|c| c.allow_mutable_hooks()).unwrap_or(false) { + debug!("Apparently mutable hooks are not allowed... failing now."); + return Err(HE::new(HEK::MutableHooksNotAllowed, None)); + } + + accessor.access_mut(fle) + }, }; trace_hook_errors(res) }) From ed66d15da883b57a5b37f2b0bb48f276bd0052f1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 10:24:10 +0200 Subject: [PATCH 062/239] The checked out branch is actually "refs/heads/master" --- imagrc.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imagrc.toml b/imagrc.toml index 29b93e22..69142ce2 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -47,7 +47,7 @@ aspect = "vcs" abort_on_repo_init_failure = true # Ensure to be on this branche before doing anything. -ensure_branch = "master" +ensure_branch = "refs/heads/master" # Try to checkout the ensure_branch if it isn't checked out try_checkout_ensure_branch = true From 30c672821d72be6b0e49ea9f4d62559321159dcd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 10:24:27 +0200 Subject: [PATCH 063/239] Add debugging output in Runtime --- libimagstorestdhook/src/vcs/git/runtime.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 6c783a66..54334f44 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -8,6 +8,7 @@ use libimagerror::trace::trace_error; use libimagstore::hook::error::CustomData; use libimagstore::hook::error::HookErrorKind as HEK; use libimagstore::hook::result::HookResult; +use libimagutil::debug_result::*; use vcs::git::result::Result; use vcs::git::error::{MapErrInto, GitHookErrorKind as GHEK}; @@ -70,18 +71,30 @@ impl Runtime { let head = try!(self .repository() .and_then(|r| { - r.head().map_err_into(GHEK::HeadFetchError).map_err(|e| e.into()) + debug!("Repository fetched, getting head"); + r.head() + .map_dbg_err_str("Couldn't fetch HEAD") + .map_dbg_err(|e| format!("\tbecause = {:?}", e)) + .map_err_into(GHEK::HeadFetchError) + .map_err(|e| e.into()) })); + debug!("HEAD fetched"); // TODO: Fail if not on branch? hmmh... I'm not sure - if head.is_branch() { + if !head.is_branch() { + debug!("HEAD is not a branch"); return Err(GHEK::NotOnBranch.into_error().into()); } + debug!("HEAD is a branch"); // Check out appropriate branch ... or fail match ensure_branch(self.config.as_ref()) { Ok(Some(s)) => { - match head.name().map(|name| name == s) { + debug!("We have to ensure branch: {}", s); + match head.name().map(|name| { + debug!("{} == {}", name, s); + name == s + }) { Some(b) => { if b { debug!("Branch already checked out."); From 79b0693fe88586fbcac543849f51b2b12d919df1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 10:24:38 +0200 Subject: [PATCH 064/239] Add debugging output in CreateHook --- libimagstorestdhook/src/vcs/git/create.rs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 43fd1c7a..42f0456d 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -82,24 +82,31 @@ impl StoreIdAccessor for CreateHook { use vcs::git::config::commit_message; debug!("[GIT CREATE HOOK]: {:?}", id); + + debug!("[GIT CREATE HOOK]: Ensuring branch checkout"); try!(self .runtime .ensure_cfg_branch_is_checked_out() .map_err(Box::new) .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e))); + debug!("[GIT CREATE HOOK]: Branch checked out"); self.runtime .config_value_or_err() + .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't get Value object from config"); e }) .and_then(|cfg| { + debug!("[GIT CREATE HOOK]: Getting repository"); self.runtime .repository() .map(|r| (r, cfg)) + .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't fetch Repository"); e }) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) }) .and_then(|(repo, cfg)| { repo.signature() .map(|s| (repo, cfg, s)) + .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't fetch Signature"); e }) .map_err_into(GHEK::RepositorySignatureFetchingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) @@ -107,6 +114,7 @@ impl StoreIdAccessor for CreateHook { .and_then(|(repo, cfg, sig)| { repo.index() .map(|idx| (repo, cfg, sig, idx)) + .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't fetch Index"); e }) .map_err_into(GHEK::RepositoryIndexFetchingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) @@ -114,6 +122,7 @@ impl StoreIdAccessor for CreateHook { .and_then(|(repo, cfg, sig, mut idx)| { idx.add_path(id) .map(|_| (repo, cfg, sig, idx)) + .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't add Path"); e }) .map_err_into(GHEK::RepositoryPathAddingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) @@ -121,6 +130,7 @@ impl StoreIdAccessor for CreateHook { .and_then(|(repo, cfg, sig, mut idx)| { idx.write_tree() .map(|oid| (repo, cfg, sig, idx, oid)) + .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't write Tree"); e }) .map_err_into(GHEK::RepositoryTreeWritingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) @@ -128,6 +138,7 @@ impl StoreIdAccessor for CreateHook { .and_then(|(repo, cfg, sig, idx, oid)| { repo.find_tree(oid) .map(|tree| (repo, cfg, sig, idx, oid, tree)) + .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't find Tree"); e }) .map_err_into(GHEK::RepositoryTreeFindingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) @@ -136,12 +147,14 @@ impl StoreIdAccessor for CreateHook { let cmtmsg = commit_message(cfg, StoreAction::Create); repo.find_commit(oid) .map(|cmt| (repo, sig, tree, cmt, cmtmsg)) + .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't find Commit"); e }) .map_err_into(GHEK::RepositoryCommitFindingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) }) .and_then(|(repo, sig, tree, cmt, commitmsg)| { repo.commit(Some("HEAD"), &sig, &sig, &commitmsg[..], &tree, &[&cmt]) + .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't create Commit"); e }) .map_err_into(GHEK::RepositoryCommittingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) From c1e430e1ff406a54d818decbfc8cfdb703428a76 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 16:17:01 +0200 Subject: [PATCH 065/239] Add error kind for error when stripping store id path prefix --- libimagstorestdhook/src/vcs/git/error.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index f7ce2cb6..9fc905f5 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -24,7 +24,8 @@ generate_error_module!( HeadFetchError => "Error while getting HEAD", NotOnBranch => "No Branch is checked out", MkRepo => "Repository creation error", - MkSignature => "Error while building Signature object" + MkSignature => "Error while building Signature object", + StoreIdStripError => "Couldn't strip prefix from StoreID object" ); ); From be34dddf876e2cce486a9da1e09b6ffbf8e8bcbc Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 16:19:14 +0200 Subject: [PATCH 066/239] Add StoreId prefix removal --- libimagstorestdhook/src/vcs/git/create.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 42f0456d..8b45961c 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -120,11 +120,12 @@ impl StoreIdAccessor for CreateHook { .map_err(|e| e.into()) }) .and_then(|(repo, cfg, sig, mut idx)| { - idx.add_path(id) + id.strip_prefix(&self.storepath) + .map_err_into(GHEK::StoreIdStripError) + .and_then(|id| idx.add_path(&id).map_err_into(GHEK::RepositoryPathAddingError)) .map(|_| (repo, cfg, sig, idx)) - .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't add Path"); e }) - .map_err_into(GHEK::RepositoryPathAddingError) .map_err_into(GHEK::RepositoryError) + .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't add Path: {:?}", e); e }) .map_err(|e| e.into()) }) .and_then(|(repo, cfg, sig, mut idx)| { From 39c3e3f7e045d282ee92a845c721b3509d07790d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 16:20:57 +0200 Subject: [PATCH 067/239] Insert dummy commit message --- libimagstorestdhook/src/vcs/git/config.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index b3cec006..32ac2698 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -9,14 +9,15 @@ use vcs::git::result::Result; use vcs::git::action::StoreAction; pub fn commit_interactive(config: &Value) -> bool { - unimplemented!() + warn!("Interactive committing not yet supported, using dummy commit message"); + false } pub fn commit_message(config: &Value, action: StoreAction) -> String { if commit_interactive(config) { unimplemented!() } else { - unimplemented!() + String::from("Dummy commit") } } From 3ea3e03cabefe7aeec55f29c89a02b6ff887d32f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 16:48:22 +0200 Subject: [PATCH 068/239] Add dependency: libimagutil --- libimagstorestdhook/Cargo.toml | 3 +++ libimagstorestdhook/src/lib.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/libimagstorestdhook/Cargo.toml b/libimagstorestdhook/Cargo.toml index 7699244a..cd1eeeb4 100644 --- a/libimagstorestdhook/Cargo.toml +++ b/libimagstorestdhook/Cargo.toml @@ -18,3 +18,6 @@ path = "../libimagentrylink" [dependencies.libimagerror] path = "../libimagerror" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/libimagstorestdhook/src/lib.rs b/libimagstorestdhook/src/lib.rs index 70c6bbc7..a99ff515 100644 --- a/libimagstorestdhook/src/lib.rs +++ b/libimagstorestdhook/src/lib.rs @@ -22,6 +22,7 @@ extern crate git2; extern crate libimagstore; extern crate libimagentrylink; #[macro_use] extern crate libimagerror; +extern crate libimagutil; pub mod debug; pub mod flock; From 3a6f469b7db92987d39145da9d59d0049dcb47c3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 29 Jul 2016 16:53:05 +0200 Subject: [PATCH 069/239] Refactor to use Result::map_dbg_err_str() --- libimagstorestdhook/src/vcs/git/create.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 8b45961c..06c1730a 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -16,6 +16,7 @@ use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; use libimagerror::trace::trace_error; use libimagerror::into::IntoError; +use libimagutil::debug_result::*; use vcs::git::result::Result; use vcs::git::error::MapErrInto; @@ -93,20 +94,20 @@ impl StoreIdAccessor for CreateHook { self.runtime .config_value_or_err() - .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't get Value object from config"); e }) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't get Value object from config") .and_then(|cfg| { debug!("[GIT CREATE HOOK]: Getting repository"); self.runtime .repository() .map(|r| (r, cfg)) - .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't fetch Repository"); e }) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch Repository") .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) }) .and_then(|(repo, cfg)| { repo.signature() .map(|s| (repo, cfg, s)) - .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't fetch Signature"); e }) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch Signature") .map_err_into(GHEK::RepositorySignatureFetchingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) @@ -114,7 +115,7 @@ impl StoreIdAccessor for CreateHook { .and_then(|(repo, cfg, sig)| { repo.index() .map(|idx| (repo, cfg, sig, idx)) - .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't fetch Index"); e }) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch Index") .map_err_into(GHEK::RepositoryIndexFetchingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) @@ -125,13 +126,13 @@ impl StoreIdAccessor for CreateHook { .and_then(|id| idx.add_path(&id).map_err_into(GHEK::RepositoryPathAddingError)) .map(|_| (repo, cfg, sig, idx)) .map_err_into(GHEK::RepositoryError) - .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't add Path: {:?}", e); e }) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't add Path: {:?}") .map_err(|e| e.into()) }) .and_then(|(repo, cfg, sig, mut idx)| { idx.write_tree() .map(|oid| (repo, cfg, sig, idx, oid)) - .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't write Tree"); e }) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't write Tree") .map_err_into(GHEK::RepositoryTreeWritingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) @@ -139,7 +140,7 @@ impl StoreIdAccessor for CreateHook { .and_then(|(repo, cfg, sig, idx, oid)| { repo.find_tree(oid) .map(|tree| (repo, cfg, sig, idx, oid, tree)) - .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't find Tree"); e }) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't find Tree") .map_err_into(GHEK::RepositoryTreeFindingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) @@ -148,14 +149,14 @@ impl StoreIdAccessor for CreateHook { let cmtmsg = commit_message(cfg, StoreAction::Create); repo.find_commit(oid) .map(|cmt| (repo, sig, tree, cmt, cmtmsg)) - .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't find Commit"); e }) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't find Commit") .map_err_into(GHEK::RepositoryCommitFindingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) }) .and_then(|(repo, sig, tree, cmt, commitmsg)| { repo.commit(Some("HEAD"), &sig, &sig, &commitmsg[..], &tree, &[&cmt]) - .map_err(|e| { debug!("[GIT CREATE HOOK]: Couldn't create Commit"); e }) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't create Commit") .map_err_into(GHEK::RepositoryCommittingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) From 3f43fa1172f7e959254a04f0ed8856522a0b8a93 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 30 Jul 2016 11:42:57 +0200 Subject: [PATCH 070/239] [TMP] --- libimagstorestdhook/src/vcs/git/create.rs | 65 ++++++++++++----------- 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 06c1730a..5e9c9f6e 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -114,49 +114,50 @@ impl StoreIdAccessor for CreateHook { }) .and_then(|(repo, cfg, sig)| { repo.index() - .map(|idx| (repo, cfg, sig, idx)) .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch Index") + .and_then(|mut idx| idx.write_tree().map(|t| (idx, t))) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't write Tree") + .and_then(|(idx, tree_id)| repo.find_tree(tree_id).map(|t| (idx, t))) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't find Tree") + .map(|(idx, tree)| (repo, cfg, sig, idx, tree)) .map_err_into(GHEK::RepositoryIndexFetchingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) }) - .and_then(|(repo, cfg, sig, mut idx)| { - id.strip_prefix(&self.storepath) - .map_err_into(GHEK::StoreIdStripError) - .and_then(|id| idx.add_path(&id).map_err_into(GHEK::RepositoryPathAddingError)) - .map(|_| (repo, cfg, sig, idx)) - .map_err_into(GHEK::RepositoryError) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't add Path: {:?}") - .map_err(|e| e.into()) - }) - .and_then(|(repo, cfg, sig, mut idx)| { - idx.write_tree() - .map(|oid| (repo, cfg, sig, idx, oid)) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't write Tree") - .map_err_into(GHEK::RepositoryTreeWritingError) + .and_then(|(repo, cfg, sig, mut idx, tree)| { + idx.add_path(id) + .map(|_| (repo, cfg, sig, idx, tree)) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't add Path") + .map_dbg_err(|_| format!("\tpath = {:?}", id)) + .map_dbg_err(|e| format!("\terr = {:?}", e)) + .map_err_into(GHEK::RepositoryPathAddingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) }) - .and_then(|(repo, cfg, sig, idx, oid)| { - repo.find_tree(oid) - .map(|tree| (repo, cfg, sig, idx, oid, tree)) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't find Tree") - .map_err_into(GHEK::RepositoryTreeFindingError) + .and_then(|(repo, cfg, sig, idx, tree)| { + repo.head() + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch HEAD") + .map_err_into(GHEK::RepositoryHeadFetchingError) + .and_then(|h| { + h.target().ok_or(GHEK::RepositoryHeadTargetFetchingError.into_error()) + }) + .and_then(|oid| { + repo.find_commit(oid) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't find commit") + .map_dbg_err(|_| format!("\toid = {:?}", oid)) + .map_err_into(GHEK::RepositoryCommitFindingError) + }) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) + .map(|parent| (repo, cfg, sig, idx, tree, parent)) }) - .and_then(|(repo, cfg, sig, idx, oid, tree)| { - let cmtmsg = commit_message(cfg, StoreAction::Create); - repo.find_commit(oid) - .map(|cmt| (repo, sig, tree, cmt, cmtmsg)) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't find Commit") - .map_err_into(GHEK::RepositoryCommitFindingError) - .map_err_into(GHEK::RepositoryError) - .map_err(|e| e.into()) - }) - .and_then(|(repo, sig, tree, cmt, commitmsg)| { - repo.commit(Some("HEAD"), &sig, &sig, &commitmsg[..], &tree, &[&cmt]) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't create Commit") + .and_then(|(repo, cfg, sig, idx, tree, parent)| { + let mut parents = vec![]; + parents.push(parent); + let parents = parents.iter().collect::>(); + let msg = commit_message(&cfg, StoreAction::Create); + repo.commit(Some("HEAD"), &sig, &sig, &msg[..], &tree, &parents) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't commit") .map_err_into(GHEK::RepositoryCommittingError) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) From ffd71b090733118bd815e398dee2f38f2dfab1be Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 2 Aug 2016 10:45:11 +0200 Subject: [PATCH 071/239] Add errors for HEAD fetching HEAD-target fetching errors --- libimagstorestdhook/src/vcs/git/error.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index 9fc905f5..be47e1e8 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -21,6 +21,8 @@ generate_error_module!( RepositoryTreeFindingError => "Error while finding repository tree", RepositoryCommitFindingError => "Error while finding commit", RepositoryCommittingError => "Error while committing", + RepositoryHeadFetchingError => "Error while fetching HEAD", + RepositoryHeadTargetFetchingError => "Error while fetching target of HEAD", HeadFetchError => "Error while getting HEAD", NotOnBranch => "No Branch is checked out", MkRepo => "Repository creation error", From 9e5932f57c4044e5e458b60137c150c771e6d5c5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 2 Aug 2016 10:53:09 +0200 Subject: [PATCH 072/239] Commit with "Initial commit" if there is no parent --- libimagstorestdhook/src/vcs/git/create.rs | 28 ++++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 5e9c9f6e..cf9aa489 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -138,24 +138,30 @@ impl StoreIdAccessor for CreateHook { repo.head() .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch HEAD") .map_err_into(GHEK::RepositoryHeadFetchingError) - .and_then(|h| { - h.target().ok_or(GHEK::RepositoryHeadTargetFetchingError.into_error()) - }) + .map(|h| h.target()) .and_then(|oid| { - repo.find_commit(oid) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't find commit") - .map_dbg_err(|_| format!("\toid = {:?}", oid)) - .map_err_into(GHEK::RepositoryCommitFindingError) + match oid { + Some(oid) => { + repo.find_commit(oid) + .map(|c| Some(c)) + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't find commit") + .map_dbg_err(|_| format!("\toid = {:?}", oid)) + .map_err_into(GHEK::RepositoryCommitFindingError) + }, + None => Ok(None), + } }) .map_err_into(GHEK::RepositoryError) .map_err(|e| e.into()) .map(|parent| (repo, cfg, sig, idx, tree, parent)) }) - .and_then(|(repo, cfg, sig, idx, tree, parent)| { - let mut parents = vec![]; - parents.push(parent); + .and_then(|(repo, cfg, sig, idx, tree, opt_parent)| { + let (msg, parents) = match opt_parent { + None => (String::from("Initial commit"), vec![]), + Some(p) => (commit_message(&cfg, StoreAction::Create), vec![p]), + }; + let parents = parents.iter().collect::>(); - let msg = commit_message(&cfg, StoreAction::Create); repo.commit(Some("HEAD"), &sig, &sig, &msg[..], &tree, &parents) .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't commit") .map_err_into(GHEK::RepositoryCommittingError) From 0e7d1730fc37632a533148c39d44ed64715b38b0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 17:13:14 +0200 Subject: [PATCH 073/239] Fix get_bool_cfg() --- libimagstorestdhook/src/vcs/git/config.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 32ac2698..0a9d5907 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -55,12 +55,12 @@ fn get_bool_cfg(cfg: Option<&Value>, name: &str, on_fail: bool, on_unavail: bool Some(&Value::Boolean(b)) => b, Some(_) => { warn!("Configuration error, '{}' must be a Boolean (true|false).", name); - warn!("Assuming 'true' now."); + warn!("Assuming '{}' now.", on_fail); on_fail }, None => { - debug!("No key '{}' - Assuming 'true'", name); - on_fail + debug!("No key '{}' - Assuming '{}'", name, on_unavail); + on_unavail }, } }) From a24981b6b6d53a83039873b8817e064f06a01614 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 17:13:57 +0200 Subject: [PATCH 074/239] use Runtime as GRuntime, for clearness --- libimagstorestdhook/src/vcs/git/create.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index cf9aa489..b587afcf 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -22,12 +22,12 @@ use vcs::git::result::Result; use vcs::git::error::MapErrInto; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::GitHookError as GHE; -use vcs::git::runtime::Runtime; +use vcs::git::runtime::Runtime as GRuntime; pub struct CreateHook { storepath: PathBuf, - runtime: Runtime, + runtime: GRuntime, position: HookPosition, } @@ -36,7 +36,7 @@ impl CreateHook { pub fn new(storepath: PathBuf, p: HookPosition) -> CreateHook { CreateHook { - runtime: Runtime::new(&storepath), + runtime: GRuntime::new(&storepath), storepath: storepath, position: p, } From 2929b772483bc550a473377e3815934c15f50b42 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 17:33:54 +0200 Subject: [PATCH 075/239] Add more error kinds --- libimagstorestdhook/src/vcs/git/error.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index be47e1e8..a2478443 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -27,7 +27,10 @@ generate_error_module!( NotOnBranch => "No Branch is checked out", MkRepo => "Repository creation error", MkSignature => "Error while building Signature object", - StoreIdStripError => "Couldn't strip prefix from StoreID object" + StoreIdHandlingError => "Error handling the store id object", + StoreIdStripError => "Couldn't strip prefix from StoreID object", + + RepositoryFileStatusError => "Error while getting file status" ); ); From 132d0d2698e57c64d666571613636fb9bb816ea9 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 17:34:08 +0200 Subject: [PATCH 076/239] Rewrite hook implementation --- libimagstorestdhook/src/vcs/git/create.rs | 126 +++++++++------------- 1 file changed, 50 insertions(+), 76 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index b587afcf..f43311a5 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -1,9 +1,11 @@ use std::path::PathBuf; +use std::path::Path; use std::fmt::{Debug, Formatter, Error as FmtError}; use std::result::Result as RResult; use toml::Value; use git2::{Reference as GitReference, Repository, Error as Git2Error}; +use git2::{ADD_DEFAULT, STATUS_WT_NEW, STATUS_WT_MODIFIED, IndexMatchedPath}; use libimagstore::storeid::StoreId; use libimagstore::hook::Hook; @@ -78,12 +80,27 @@ impl HookDataAccessorProvider for CreateHook { impl StoreIdAccessor for CreateHook { + /// The implementation of the CreateHook + /// + /// # Scope + /// + /// What this function has to do is _adding_ the new entry to the git index. + /// After that, the UpdateHook will take care of committing the changes or new file. + /// fn access(&self, id: &StoreId) -> HookResult<()> { use vcs::git::action::StoreAction; use vcs::git::config::commit_message; debug!("[GIT CREATE HOOK]: {:?}", id); + let path = try!(id.into_pathbuf().map_err_into(GHEK::StoreIdHandlingError)); + + let cfg = try!( + self.runtime + .config_value_or_err() + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't get Value object from config") + ); + debug!("[GIT CREATE HOOK]: Ensuring branch checkout"); try!(self .runtime @@ -92,83 +109,40 @@ impl StoreIdAccessor for CreateHook { .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e))); debug!("[GIT CREATE HOOK]: Branch checked out"); - self.runtime - .config_value_or_err() - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't get Value object from config") - .and_then(|cfg| { - debug!("[GIT CREATE HOOK]: Getting repository"); - self.runtime - .repository() - .map(|r| (r, cfg)) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch Repository") - .map_err_into(GHEK::RepositoryError) - .map_err(|e| e.into()) - }) - .and_then(|(repo, cfg)| { - repo.signature() - .map(|s| (repo, cfg, s)) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch Signature") - .map_err_into(GHEK::RepositorySignatureFetchingError) - .map_err_into(GHEK::RepositoryError) - .map_err(|e| e.into()) - }) - .and_then(|(repo, cfg, sig)| { - repo.index() - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch Index") - .and_then(|mut idx| idx.write_tree().map(|t| (idx, t))) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't write Tree") - .and_then(|(idx, tree_id)| repo.find_tree(tree_id).map(|t| (idx, t))) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't find Tree") - .map(|(idx, tree)| (repo, cfg, sig, idx, tree)) - .map_err_into(GHEK::RepositoryIndexFetchingError) - .map_err_into(GHEK::RepositoryError) - .map_err(|e| e.into()) - }) - .and_then(|(repo, cfg, sig, mut idx, tree)| { - idx.add_path(id) - .map(|_| (repo, cfg, sig, idx, tree)) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't add Path") - .map_dbg_err(|_| format!("\tpath = {:?}", id)) - .map_dbg_err(|e| format!("\terr = {:?}", e)) - .map_err_into(GHEK::RepositoryPathAddingError) - .map_err_into(GHEK::RepositoryError) - .map_err(|e| e.into()) - }) - .and_then(|(repo, cfg, sig, idx, tree)| { - repo.head() - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch HEAD") - .map_err_into(GHEK::RepositoryHeadFetchingError) - .map(|h| h.target()) - .and_then(|oid| { - match oid { - Some(oid) => { - repo.find_commit(oid) - .map(|c| Some(c)) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't find commit") - .map_dbg_err(|_| format!("\toid = {:?}", oid)) - .map_err_into(GHEK::RepositoryCommitFindingError) - }, - None => Ok(None), - } - }) - .map_err_into(GHEK::RepositoryError) - .map_err(|e| e.into()) - .map(|parent| (repo, cfg, sig, idx, tree, parent)) - }) - .and_then(|(repo, cfg, sig, idx, tree, opt_parent)| { - let (msg, parents) = match opt_parent { - None => (String::from("Initial commit"), vec![]), - Some(p) => (commit_message(&cfg, StoreAction::Create), vec![p]), - }; + debug!("[GIT CREATE HOOK]: Getting repository"); + let repo = try!( + self.runtime + .repository() + .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch Repository") + .map_err_into(GHEK::RepositoryError) + .map_err(|e| e.into()) + ); + debug!("[GIT CREATE HOOK]: Repository object fetched"); - let parents = parents.iter().collect::>(); - repo.commit(Some("HEAD"), &sig, &sig, &msg[..], &tree, &parents) - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't commit") - .map_err_into(GHEK::RepositoryCommittingError) - .map_err_into(GHEK::RepositoryError) - .map_err(|e| e.into()) - }) - .map(|_| ()) + let index = try!(repo.index().map_err_into(GHEK::RepositoryIndexFetchingError)); + + let file_status = try!( + repo.status_file(&path).map_err_into(GHEK::RepositoryFileStatusError) + ); + + let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { + if file_status.contains(STATUS_WT_MODIFIED) || + file_status.contains(STATUS_WT_NEW) { + + debug!("[GIT CREATE HOOK]: File is new or modified: {}", path.display()); + 0 + } else { + debug!("[GIT CREATE HOOK]: Ignoring file: {}", path.display()); + 1 + } + }; + + try!( + index.add_all(&[path], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) + .map_err_into(GHEK::RepositoryPathAddingError) + ); + + index.write().map_err_into(GHEK::RepositoryIndexWritingError).map_err(|e| e.into()) } } From ca94a6cb7c585f89da068882d3d7cc2e17e90bac Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 18:25:45 +0200 Subject: [PATCH 077/239] Add error kind for index writing error --- libimagstorestdhook/src/vcs/git/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index a2478443..0c5cab3f 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -16,6 +16,7 @@ generate_error_module!( RepositoryBranchNameFetchingError => "Error while fetching branch name", RepositorySignatureFetchingError => "Error while fetching Authors/Committers signature", RepositoryIndexFetchingError => "Error while fetching Repository Index", + RepositoryIndexWritingError => "Error while writing Repository Index", RepositoryPathAddingError => "Error while adding Path to Index", RepositoryTreeWritingError => "Error while writing repository tree", RepositoryTreeFindingError => "Error while finding repository tree", From ec1b5f7e8b0674baeb704652464326ea78e3d279 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 18:36:32 +0200 Subject: [PATCH 078/239] Add IntoHookError for convenience function map_into_hook_error() --- libimagstorestdhook/src/vcs/git/error.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index 0c5cab3f..1ad15a3d 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -59,6 +59,18 @@ impl From for GitHookError { } +pub trait MapIntoHookError { + fn map_into_hook_error(self) -> Result; +} + +impl MapIntoHookError for Result { + + fn map_into_hook_error(self) -> Result { + self.map_err(|e| HE::new(HEK::HookExecutionError, Some(Box::new(e)))) + } + +} + pub use self::error::GitHookError; pub use self::error::GitHookErrorKind; pub use self::error::MapErrInto; From ced6342d01f90d08d5024e5a638e277a1233494a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 18:39:47 +0200 Subject: [PATCH 079/239] Use MapIntoHookError for mapping into hook error --- libimagstorestdhook/src/vcs/git/create.rs | 35 ++++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index f43311a5..54845cdd 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -21,6 +21,7 @@ use libimagerror::into::IntoError; use libimagutil::debug_result::*; use vcs::git::result::Result; +use vcs::git::error::MapIntoHookError; use vcs::git::error::MapErrInto; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::GitHookError as GHE; @@ -90,10 +91,16 @@ impl StoreIdAccessor for CreateHook { fn access(&self, id: &StoreId) -> HookResult<()> { use vcs::git::action::StoreAction; use vcs::git::config::commit_message; + use vcs::git::error::MapIntoHookError; debug!("[GIT CREATE HOOK]: {:?}", id); - let path = try!(id.into_pathbuf().map_err_into(GHEK::StoreIdHandlingError)); + let path = try!( + id.clone() + .into_pathbuf() + .map_err_into(GHEK::StoreIdHandlingError) + .map_into_hook_error() + ); let cfg = try!( self.runtime @@ -102,11 +109,7 @@ impl StoreIdAccessor for CreateHook { ); debug!("[GIT CREATE HOOK]: Ensuring branch checkout"); - try!(self - .runtime - .ensure_cfg_branch_is_checked_out() - .map_err(Box::new) - .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e))); + try!(self.runtime.ensure_cfg_branch_is_checked_out()); debug!("[GIT CREATE HOOK]: Branch checked out"); debug!("[GIT CREATE HOOK]: Getting repository"); @@ -115,14 +118,22 @@ impl StoreIdAccessor for CreateHook { .repository() .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch Repository") .map_err_into(GHEK::RepositoryError) - .map_err(|e| e.into()) + .map_into_hook_error() ); debug!("[GIT CREATE HOOK]: Repository object fetched"); - let index = try!(repo.index().map_err_into(GHEK::RepositoryIndexFetchingError)); + let mut index = try!( + repo + .index() + .map_err_into(GHEK::RepositoryIndexFetchingError) + .map_into_hook_error() + ); let file_status = try!( - repo.status_file(&path).map_err_into(GHEK::RepositoryFileStatusError) + repo + .status_file(&path) + .map_err_into(GHEK::RepositoryFileStatusError) + .map_into_hook_error() ); let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { @@ -140,9 +151,13 @@ impl StoreIdAccessor for CreateHook { try!( index.add_all(&[path], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) .map_err_into(GHEK::RepositoryPathAddingError) + .map_into_hook_error() ); - index.write().map_err_into(GHEK::RepositoryIndexWritingError).map_err(|e| e.into()) + index + .write() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_into_hook_error() } } From c9c535f46c8abb5c673706e638f50da69a1b26d5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 20:54:35 +0200 Subject: [PATCH 080/239] Add Runtime for UpdateHook --- libimagstorestdhook/src/vcs/git/update.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 4a5026d0..388a1929 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -9,21 +9,24 @@ use libimagstore::hook::position::HookPosition; use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; +use vcs::git::runtime::Runtime as GRuntime; + #[derive(Debug)] pub struct UpdateHook { storepath: PathBuf, + runtime: GRuntime, + position: HookPosition, - config: Option, } impl UpdateHook { pub fn new(storepath: PathBuf, p: HookPosition) -> UpdateHook { UpdateHook { + runtime: GRuntime::new(&storepath), storepath: storepath, position: p, - config: None, } } From bcf91780aaed3b7345e1ede3095c23200ac573b3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 20:54:44 +0200 Subject: [PATCH 081/239] impl Debug for UpdateHook --- libimagstorestdhook/src/vcs/git/update.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 388a1929..86cdb6d3 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -11,7 +11,6 @@ use libimagstore::hook::accessor::StoreIdAccessor; use vcs::git::runtime::Runtime as GRuntime; -#[derive(Debug)] pub struct UpdateHook { storepath: PathBuf, @@ -32,6 +31,16 @@ impl UpdateHook { } +impl Debug for UpdateHook { + fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { + write!(fmt, "UpdateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}", + self.storepath, + (if self.runtime.has_repository() { "Some(_)" } else { "None" }), + self.position, + self.runtime.has_config()) + } +} + impl Hook for UpdateHook { fn name(&self) -> &'static str { From 6444f95b58e4fcf9adc56e0b4d1f7a06ef08055d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 20:54:57 +0200 Subject: [PATCH 082/239] Reimplement Hook::set_config() for UpdateHook --- libimagstorestdhook/src/vcs/git/update.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 86cdb6d3..df1fba18 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -48,7 +48,9 @@ impl Hook for UpdateHook { } fn set_config(&mut self, config: &Value) { - self.config = Some(config.clone()); + if let Err(e) = self.runtime.set_config(config) { + trace_error(&e); + } } } From 242fa863b2379063f09e33d15fbd69c8cebb1ae2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:13:05 +0200 Subject: [PATCH 083/239] The helper commit_message() really should return an Result --- libimagstorestdhook/src/vcs/git/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 0a9d5907..a7e262d6 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -13,11 +13,11 @@ pub fn commit_interactive(config: &Value) -> bool { false } -pub fn commit_message(config: &Value, action: StoreAction) -> String { +pub fn commit_message(config: &Value, action: StoreAction) -> Result { if commit_interactive(config) { unimplemented!() } else { - String::from("Dummy commit") + Ok(String::from("Dummy commit")) } } From 6ef6262e54d8cb83fec2ad7f7f6410c180baf2a9 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:13:29 +0200 Subject: [PATCH 084/239] Add error kind for parent fetching error --- libimagstorestdhook/src/vcs/git/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index 1ad15a3d..a8a00e14 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -24,6 +24,7 @@ generate_error_module!( RepositoryCommittingError => "Error while committing", RepositoryHeadFetchingError => "Error while fetching HEAD", RepositoryHeadTargetFetchingError => "Error while fetching target of HEAD", + RepositoryParentFetchingError => "Error while fetching parent of commit", HeadFetchError => "Error while getting HEAD", NotOnBranch => "No Branch is checked out", MkRepo => "Repository creation error", From 513a99fca76dd3c12909c912771e48ecb678642c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:13:40 +0200 Subject: [PATCH 085/239] Add initial implementation for UpdateHook --- libimagstorestdhook/src/vcs/git/update.rs | 100 ++++++++++++++++++++-- 1 file changed, 95 insertions(+), 5 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index df1fba18..b0d2d05e 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -1,14 +1,26 @@ use std::path::PathBuf; +use std::fmt::{Debug, Formatter, Error as FmtError}; +use std::result::Result as RResult; use toml::Value; -use libimagstore::storeid::StoreId; +use libimagerror::into::IntoError; +use libimagerror::trace::trace_error; use libimagstore::hook::Hook; -use libimagstore::hook::result::HookResult; -use libimagstore::hook::position::HookPosition; -use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; +use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; +use libimagstore::hook::error::HookError as HE; +use libimagstore::hook::error::HookErrorKind as HEK; +use libimagstore::hook::position::HookPosition; +use libimagstore::hook::result::HookResult; +use libimagstore::storeid::StoreId; +use libimagutil::debug_result::*; +use vcs::git::error::GitHookError as GHE; +use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::error::MapErrInto; +use vcs::git::error::MapIntoHookError; +use vcs::git::result::Result; use vcs::git::runtime::Runtime as GRuntime; pub struct UpdateHook { @@ -64,9 +76,87 @@ impl HookDataAccessorProvider for UpdateHook { impl StoreIdAccessor for UpdateHook { + /// The implementation of the UpdateHook + /// + /// # Scope + /// + /// This hook takes the git index and commits it either interactively or with a default message, + /// if there is no configuration for an interactive commit. + /// fn access(&self, id: &StoreId) -> HookResult<()> { + use vcs::git::action::StoreAction; + use vcs::git::config::commit_message; + use vcs::git::error::MapIntoHookError; + debug!("[GIT UPDATE HOOK]: {:?}", id); - Ok(()) + + let cfg = try!( + self.runtime + .config_value_or_err() + .map_dbg_err_str("[GIT UPDATE HOOK]: Couldn't get Value object from config") + ); + + debug!("[GIT UPDATE HOOK]: Getting repository"); + let repo = try!( + self.runtime + .repository() + .map_dbg_err_str("[GIT UPDATE HOOK]: Couldn't fetch Repository") + .map_err_into(GHEK::RepositoryError) + .map_into_hook_error() + ); + debug!("[GIT UPDATE HOOK]: Repository object fetched"); + + let mut index = try!( + repo + .index() + .map_err_into(GHEK::RepositoryIndexFetchingError) + .map_into_hook_error() + ); + + let tree_id = try!( + index.write_tree() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_into_hook_error() + ); + + let signature = try!( + repo.signature() + .map_err_into(GHEK::MkSignature) + .map_into_hook_error() + ); + + let head = try!( + repo.head() + .map_err_into(GHEK::HeadFetchError) + .map_into_hook_error() + ); + + let mut parents = Vec::new(); + { + let commit = try!( + repo.find_commit(head.target().unwrap()) + .map_err_into(GHEK::RepositoryParentFetchingError) + .map_into_hook_error() + ); + parents.push(commit); + } + + // for converting from Vec to Vec<&Commit> + let parents = parents.iter().collect::>(); + + let tree = try!( + repo.find_tree(tree_id) + .map_err_into(GHEK::RepositoryParentFetchingError) + .map_into_hook_error() + ); + + let message = try!(commit_message(cfg, StoreAction::Update)); + + repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) + .map_err_into(GHEK::RepositoryCommittingError) + .map_into_hook_error() + .map(|_| ()) + } } From 9c2f4db03d3577243f53ca0da9c5bf6d7d856aec Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:26:06 +0200 Subject: [PATCH 086/239] Remove unused fn: hasrepo() --- libimagstorestdhook/src/vcs/git/util.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index e57e6acc..5a6f0b86 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -22,7 +22,3 @@ pub fn mkrepo(store: &Store) -> Result<()> { .map_err_into(GHEK::MkRepo) } -pub fn hasrepo(store: &Store) -> bool { - Repository::open(store.path()).is_ok() -} - From fddd6ec4cb8b36a163e955baa7214f48f34a9c25 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:26:23 +0200 Subject: [PATCH 087/239] Remove unused fn: mkrepo() --- libimagstorestdhook/src/vcs/git/util.rs | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index 5a6f0b86..0a022a9a 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -11,14 +11,3 @@ use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; use vcs::git::result::Result; -pub fn mkrepo(store: &Store) -> Result<()> { - let mut opts = RepositoryInitOptions::new(); - opts.bare(false); - opts.no_reinit(true); - opts.mkdir(false); - opts.external_template(false); - Repository::init_opts(store.path(), &opts) - .map(|_| ()) - .map_err_into(GHEK::MkRepo) -} - From 741ebff2da3c115e76ab7e732564628152b72de5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:32:11 +0200 Subject: [PATCH 088/239] Outsource repository fetching into helper fn --- libimagstorestdhook/src/vcs/git/create.rs | 13 +++++-------- libimagstorestdhook/src/vcs/git/update.rs | 13 +++++-------- libimagstorestdhook/src/vcs/git/util.rs | 19 +++++++++++++++---- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 54845cdd..d3df670d 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -92,6 +92,7 @@ impl StoreIdAccessor for CreateHook { use vcs::git::action::StoreAction; use vcs::git::config::commit_message; use vcs::git::error::MapIntoHookError; + use vcs::git::util::fetch_repo; debug!("[GIT CREATE HOOK]: {:?}", id); @@ -112,15 +113,11 @@ impl StoreIdAccessor for CreateHook { try!(self.runtime.ensure_cfg_branch_is_checked_out()); debug!("[GIT CREATE HOOK]: Branch checked out"); - debug!("[GIT CREATE HOOK]: Getting repository"); - let repo = try!( - self.runtime - .repository() - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't fetch Repository") - .map_err_into(GHEK::RepositoryError) - .map_into_hook_error() + let repo = try!(fetch_repo(&self.runtime, + "[GIT CREATE HOOK]: Getting repository", + "[GIT CREATE HOOK]: Couldn't fetch Repository", + "[GIT CREATE HOOK]: Repository object fetched") ); - debug!("[GIT CREATE HOOK]: Repository object fetched"); let mut index = try!( repo diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index b0d2d05e..e423c0de 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -87,6 +87,7 @@ impl StoreIdAccessor for UpdateHook { use vcs::git::action::StoreAction; use vcs::git::config::commit_message; use vcs::git::error::MapIntoHookError; + use vcs::git::util::fetch_repo; debug!("[GIT UPDATE HOOK]: {:?}", id); @@ -96,15 +97,11 @@ impl StoreIdAccessor for UpdateHook { .map_dbg_err_str("[GIT UPDATE HOOK]: Couldn't get Value object from config") ); - debug!("[GIT UPDATE HOOK]: Getting repository"); - let repo = try!( - self.runtime - .repository() - .map_dbg_err_str("[GIT UPDATE HOOK]: Couldn't fetch Repository") - .map_err_into(GHEK::RepositoryError) - .map_into_hook_error() + let repo = try!(fetch_repo(&self.runtime, + "[GIT UPDATE HOOK]: Getting repository", + "[GIT UPDATE HOOK]: Couldn't fetch Repository", + "[GIT UPDATE HOOK]: Repository object fetched") ); - debug!("[GIT UPDATE HOOK]: Repository object fetched"); let mut index = try!( repo diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index 0a022a9a..a87fc6dd 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -3,11 +3,22 @@ //! Contains primitives to create a repository within the store path use git2::Repository; -use git2::RepositoryInitOptions; - -use libimagstore::store::Store; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; -use vcs::git::result::Result; +use vcs::git::runtime::Runtime as GRuntime; +use vcs::git::action::StoreAction; +use vcs::git::error::MapIntoHookError; + +use libimagutil::debug_result::*; +use libimagstore::hook::error::HookError; + +pub fn fetch_repo<'a>(runtime: &'a GRuntime, action: &StoreAction) -> Result<&'a Repository, HookError> +{ + runtime + .repository() + .map_dbg_err_str(on_err_str) + .map_err_into(GHEK::RepositoryError) + .map_into_hook_error() +} From ca477441088b68a84dd8fa6f29a2f72686b78574 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:37:08 +0200 Subject: [PATCH 089/239] Add StoreAction::uppercase() utility function For debugging output convenience --- libimagstorestdhook/src/vcs/git/action.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/action.rs b/libimagstorestdhook/src/vcs/git/action.rs index 26caf5a0..277260f0 100644 --- a/libimagstorestdhook/src/vcs/git/action.rs +++ b/libimagstorestdhook/src/vcs/git/action.rs @@ -8,6 +8,18 @@ pub enum StoreAction { Delete, } +impl StoreAction { + + pub fn uppercase(&self) -> &str { + match *self { + StoreAction::Create => "CREATE", + StoreAction::Retrieve => "RETRIEVE", + StoreAction::Update => "UPDATE", + StoreAction::Delete => "DELETE", + } + } +} + impl Display for StoreAction { fn fmt(&self, fmt: &mut Formatter) -> Result<(), Error> { From 032110e6d83229a8bc82b6e47f13ce91f155fa14 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:37:56 +0200 Subject: [PATCH 090/239] Rewrite fetch_repo() so we have less overhead in calling this helper --- libimagstorestdhook/src/vcs/git/create.rs | 8 +++----- libimagstorestdhook/src/vcs/git/update.rs | 8 +++----- libimagstorestdhook/src/vcs/git/util.rs | 4 +++- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index d3df670d..079b1b60 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -113,11 +113,9 @@ impl StoreIdAccessor for CreateHook { try!(self.runtime.ensure_cfg_branch_is_checked_out()); debug!("[GIT CREATE HOOK]: Branch checked out"); - let repo = try!(fetch_repo(&self.runtime, - "[GIT CREATE HOOK]: Getting repository", - "[GIT CREATE HOOK]: Couldn't fetch Repository", - "[GIT CREATE HOOK]: Repository object fetched") - ); + let action = StoreAction::Create; + + let repo = try!(fetch_repo(&self.runtime, &action)); let mut index = try!( repo diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index e423c0de..1c91fa78 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -97,11 +97,9 @@ impl StoreIdAccessor for UpdateHook { .map_dbg_err_str("[GIT UPDATE HOOK]: Couldn't get Value object from config") ); - let repo = try!(fetch_repo(&self.runtime, - "[GIT UPDATE HOOK]: Getting repository", - "[GIT UPDATE HOOK]: Couldn't fetch Repository", - "[GIT UPDATE HOOK]: Repository object fetched") - ); + let action = StoreAction::Update; + + let repo = try!(fetch_repo(&self.runtime, &action)); let mut index = try!( repo diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index a87fc6dd..6bdd954d 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -15,9 +15,11 @@ use libimagstore::hook::error::HookError; pub fn fetch_repo<'a>(runtime: &'a GRuntime, action: &StoreAction) -> Result<&'a Repository, HookError> { + debug!("[GIT {} HOOK]: Getting repository", action.uppercase()); runtime .repository() - .map_dbg_err_str(on_err_str) + .map_dbg_err(|_| format!("[GIT {} HOOK]: Couldn't fetch Repository", action.uppercase())) + .map_dbg(|_| format!("[GIT {} HOOK]: Repository object fetched", action.uppercase())) .map_err_into(GHEK::RepositoryError) .map_into_hook_error() } From 4e2a980599a506789b3994545fdbe17fcb858ea2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:47:39 +0200 Subject: [PATCH 091/239] Refactor Index fetching into helper function --- libimagstorestdhook/src/vcs/git/create.rs | 15 ++++----------- libimagstorestdhook/src/vcs/git/update.rs | 15 ++++----------- libimagstorestdhook/src/vcs/git/util.rs | 11 ++++++++++- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 079b1b60..737c7402 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -92,7 +92,7 @@ impl StoreIdAccessor for CreateHook { use vcs::git::action::StoreAction; use vcs::git::config::commit_message; use vcs::git::error::MapIntoHookError; - use vcs::git::util::fetch_repo; + use vcs::git::util::{fetch_repo, fetch_index}; debug!("[GIT CREATE HOOK]: {:?}", id); @@ -113,16 +113,9 @@ impl StoreIdAccessor for CreateHook { try!(self.runtime.ensure_cfg_branch_is_checked_out()); debug!("[GIT CREATE HOOK]: Branch checked out"); - let action = StoreAction::Create; - - let repo = try!(fetch_repo(&self.runtime, &action)); - - let mut index = try!( - repo - .index() - .map_err_into(GHEK::RepositoryIndexFetchingError) - .map_into_hook_error() - ); + let action = StoreAction::Create; + let repo = try!(fetch_repo(&self.runtime, &action)); + let mut index = try!(fetch_index(repo, &action)); let file_status = try!( repo diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 1c91fa78..9bd7f65a 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -87,7 +87,7 @@ impl StoreIdAccessor for UpdateHook { use vcs::git::action::StoreAction; use vcs::git::config::commit_message; use vcs::git::error::MapIntoHookError; - use vcs::git::util::fetch_repo; + use vcs::git::util::{fetch_repo, fetch_index}; debug!("[GIT UPDATE HOOK]: {:?}", id); @@ -97,16 +97,9 @@ impl StoreIdAccessor for UpdateHook { .map_dbg_err_str("[GIT UPDATE HOOK]: Couldn't get Value object from config") ); - let action = StoreAction::Update; - - let repo = try!(fetch_repo(&self.runtime, &action)); - - let mut index = try!( - repo - .index() - .map_err_into(GHEK::RepositoryIndexFetchingError) - .map_into_hook_error() - ); + let action = StoreAction::Update; + let repo = try!(fetch_repo(&self.runtime, &action)); + let mut index = try!(fetch_index(repo, &action)); let tree_id = try!( index.write_tree() diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index 6bdd954d..7e0a9f4d 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -2,7 +2,7 @@ //! //! Contains primitives to create a repository within the store path -use git2::Repository; +use git2::{Repository, Index}; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; @@ -24,3 +24,12 @@ pub fn fetch_repo<'a>(runtime: &'a GRuntime, action: &StoreAction) -> Result<&'a .map_into_hook_error() } +pub fn fetch_index(repo: &Repository, action: &StoreAction) -> Result { + debug!("[GIT {} HOOK]: Getting Index", action.uppercase()); + repo.index() + .map_dbg_err(|_| format!("[GIT {} HOOK]: Couldn't fetch Index", action.uppercase())) + .map_dbg(|_| format!("[GIT {} HOOK]: Index object fetched", action.uppercase())) + .map_err_into(GHEK::RepositoryIndexFetchingError) + .map_into_hook_error() +} + From f86b450cfa6bbc5e11ec575d659f9567f4cd347d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:51:34 +0200 Subject: [PATCH 092/239] Simplify error printing if config value fetching failed --- libimagstorestdhook/src/vcs/git/create.rs | 7 +------ libimagstorestdhook/src/vcs/git/runtime.rs | 5 ++++- libimagstorestdhook/src/vcs/git/update.rs | 7 +------ 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 737c7402..9708f0e9 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -103,17 +103,12 @@ impl StoreIdAccessor for CreateHook { .map_into_hook_error() ); - let cfg = try!( - self.runtime - .config_value_or_err() - .map_dbg_err_str("[GIT CREATE HOOK]: Couldn't get Value object from config") - ); - debug!("[GIT CREATE HOOK]: Ensuring branch checkout"); try!(self.runtime.ensure_cfg_branch_is_checked_out()); debug!("[GIT CREATE HOOK]: Branch checked out"); let action = StoreAction::Create; + let cfg = try!(self.runtime.config_value_or_err(&action)); let repo = try!(fetch_repo(&self.runtime, &action)); let mut index = try!(fetch_index(repo, &action)); diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 54334f44..dd53de95 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -47,7 +47,7 @@ impl Runtime { self.config.is_some() } - pub fn config_value_or_err(&self) -> HookResult<&Value> { + pub fn config_value_or_err(&self, action: &StoreAction) -> HookResult<&Value> { self.config .as_ref() .ok_or(GHEK::NoConfigError.into_error()) @@ -55,6 +55,9 @@ impl Runtime { .map_err(Box::new) .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)) .map_err(|mut e| e.with_custom_data(CustomData::default().aborting(false))) + .map_dbg_err(|_| { + format!("[GIT {} HOOK]: Couldn't get Value object from config", action.uppercase()) + }) } pub fn repository(&self) -> HookResult<&Repository> { diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 9bd7f65a..9d5d18eb 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -91,13 +91,8 @@ impl StoreIdAccessor for UpdateHook { debug!("[GIT UPDATE HOOK]: {:?}", id); - let cfg = try!( - self.runtime - .config_value_or_err() - .map_dbg_err_str("[GIT UPDATE HOOK]: Couldn't get Value object from config") - ); - let action = StoreAction::Update; + let cfg = try!(self.runtime.config_value_or_err(&action)); let repo = try!(fetch_repo(&self.runtime, &action)); let mut index = try!(fetch_index(repo, &action)); From b50aacbf55ec13653320fd1bcc1aa12303c3f93f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:54:20 +0200 Subject: [PATCH 093/239] Move error output to Runtime::repository() getter --- libimagstorestdhook/src/vcs/git/create.rs | 4 ++-- libimagstorestdhook/src/vcs/git/runtime.rs | 12 +++++++++--- libimagstorestdhook/src/vcs/git/update.rs | 4 ++-- libimagstorestdhook/src/vcs/git/util.rs | 11 ----------- 4 files changed, 13 insertions(+), 18 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 9708f0e9..c8ada38a 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -92,7 +92,7 @@ impl StoreIdAccessor for CreateHook { use vcs::git::action::StoreAction; use vcs::git::config::commit_message; use vcs::git::error::MapIntoHookError; - use vcs::git::util::{fetch_repo, fetch_index}; + use vcs::git::util::fetch_index; debug!("[GIT CREATE HOOK]: {:?}", id); @@ -109,7 +109,7 @@ impl StoreIdAccessor for CreateHook { let action = StoreAction::Create; let cfg = try!(self.runtime.config_value_or_err(&action)); - let repo = try!(fetch_repo(&self.runtime, &action)); + let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); let file_status = try!( diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index dd53de95..74ed8fb3 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -10,6 +10,7 @@ use libimagstore::hook::error::HookErrorKind as HEK; use libimagstore::hook::result::HookResult; use libimagutil::debug_result::*; +use vcs::git::action::StoreAction; use vcs::git::result::Result; use vcs::git::error::{MapErrInto, GitHookErrorKind as GHEK}; @@ -60,12 +61,17 @@ impl Runtime { }) } - pub fn repository(&self) -> HookResult<&Repository> { + pub fn repository(&self, action: &StoreAction) -> HookResult<&Repository> { + use vcs::git::error::MapIntoHookError; + + debug!("[GIT {} HOOK]: Getting repository", action.uppercase()); self.repository .as_ref() .ok_or(GHEK::MkRepo.into_error()) - .map_err(Box::new) - .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)) + .map_err_into(GHEK::RepositoryError) + .map_into_hook_error() + .map_dbg_err(|_| format!("[GIT {} HOOK]: Couldn't fetch Repository", action.uppercase())) + .map_dbg(|_| format!("[GIT {} HOOK]: Repository object fetched", action.uppercase())) } pub fn ensure_cfg_branch_is_checked_out(&self) -> HookResult<()> { diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 9d5d18eb..fa4af2c9 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -87,13 +87,13 @@ impl StoreIdAccessor for UpdateHook { use vcs::git::action::StoreAction; use vcs::git::config::commit_message; use vcs::git::error::MapIntoHookError; - use vcs::git::util::{fetch_repo, fetch_index}; + use vcs::git::util::fetch_index; debug!("[GIT UPDATE HOOK]: {:?}", id); let action = StoreAction::Update; let cfg = try!(self.runtime.config_value_or_err(&action)); - let repo = try!(fetch_repo(&self.runtime, &action)); + let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); let tree_id = try!( diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index 7e0a9f4d..56b66323 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -13,17 +13,6 @@ use vcs::git::error::MapIntoHookError; use libimagutil::debug_result::*; use libimagstore::hook::error::HookError; -pub fn fetch_repo<'a>(runtime: &'a GRuntime, action: &StoreAction) -> Result<&'a Repository, HookError> -{ - debug!("[GIT {} HOOK]: Getting repository", action.uppercase()); - runtime - .repository() - .map_dbg_err(|_| format!("[GIT {} HOOK]: Couldn't fetch Repository", action.uppercase())) - .map_dbg(|_| format!("[GIT {} HOOK]: Repository object fetched", action.uppercase())) - .map_err_into(GHEK::RepositoryError) - .map_into_hook_error() -} - pub fn fetch_index(repo: &Repository, action: &StoreAction) -> Result { debug!("[GIT {} HOOK]: Getting Index", action.uppercase()); repo.index() From c19f269f59e99db69e4c5673d82450df12e2c5a4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 21:57:10 +0200 Subject: [PATCH 094/239] Adapt ensure_cfg_branch_is_checked_out() for new Runtime::repository() interface --- libimagstorestdhook/src/vcs/git/create.rs | 6 ++---- libimagstorestdhook/src/vcs/git/runtime.rs | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index c8ada38a..fcba4535 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -103,11 +103,9 @@ impl StoreIdAccessor for CreateHook { .map_into_hook_error() ); - debug!("[GIT CREATE HOOK]: Ensuring branch checkout"); - try!(self.runtime.ensure_cfg_branch_is_checked_out()); - debug!("[GIT CREATE HOOK]: Branch checked out"); - let action = StoreAction::Create; + try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); + let cfg = try!(self.runtime.config_value_or_err(&action)); let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 74ed8fb3..13902b7d 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -74,11 +74,12 @@ impl Runtime { .map_dbg(|_| format!("[GIT {} HOOK]: Repository object fetched", action.uppercase())) } - pub fn ensure_cfg_branch_is_checked_out(&self) -> HookResult<()> { + pub fn ensure_cfg_branch_is_checked_out(&self, action: &StoreAction) -> HookResult<()> { use vcs::git::config::ensure_branch; + debug!("[GIT CREATE HOOK]: Ensuring branch checkout"); let head = try!(self - .repository() + .repository(action) .and_then(|r| { debug!("Repository fetched, getting head"); r.head() @@ -128,6 +129,7 @@ impl Runtime { } .map_err(Box::new) .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)) + .map_dbg_str("[GIT CREATE HOOK]: Branch checked out") } } From 157f4e79aaa8b8b14f9fcfe050f1f7ee5c1857eb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 09:17:22 +0200 Subject: [PATCH 095/239] test setup: Prepare store directory before starting tests --- tests/utils.sh | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/utils.sh b/tests/utils.sh index 6480337d..57c5b079 100644 --- a/tests/utils.sh +++ b/tests/utils.sh @@ -47,10 +47,16 @@ cat_entry() { } reset_store() { + rm -rf "${STORE}"/.git rm -r "${STORE}" } call_test() { + prepare_store_directory || { + err "Preparing store directory failed" + exit 1 + } + out "-- TESTING: '$1' --" $1 result=$? @@ -63,6 +69,27 @@ call_test() { success "-- SUCCESS: '$1' --" } +__git() { + out "Calling git: $*" + git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git $* +} + +__git_commit() { + out "Calling git-commit: $*" + git --work-tree=/tmp/store/ --git-dir=/tmp/store/.git commit -m "$*" +} + +prepare_store_directory() { + out "Preparing /tmp/store" + mkdir -p /tmp/store/ &&\ + touch /tmp/store/.gitkeep &&\ + __git init &&\ + __git config --local user.email "imag@imag-pim.org" &&\ + __git config --local user.name "Imag CI" &&\ + __git add .gitkeep &&\ + __git_commit 'Initial commit: .gitkeep' +} + invoke_tests() { out "Invoking tests." if [[ ! -z "$INVOKE_TEST" ]]; then From 8f01cf15e422ab63774116129c56a512339758f0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 09:32:25 +0200 Subject: [PATCH 096/239] Move hook impl to update hook as Store::create() is lazy As Store::create() is lazy and does not write to disk, we do not have a file on disk when the post-create-hook runs. Therefor, the implementation of the git logic has to be in the update hook. --- libimagstorestdhook/src/vcs/git/create.rs | 51 +---------------------- libimagstorestdhook/src/vcs/git/update.rs | 33 +++++++++++++++ 2 files changed, 35 insertions(+), 49 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index fcba4535..335bf2a6 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -89,56 +89,9 @@ impl StoreIdAccessor for CreateHook { /// After that, the UpdateHook will take care of committing the changes or new file. /// fn access(&self, id: &StoreId) -> HookResult<()> { - use vcs::git::action::StoreAction; - use vcs::git::config::commit_message; - use vcs::git::error::MapIntoHookError; - use vcs::git::util::fetch_index; - debug!("[GIT CREATE HOOK]: {:?}", id); - - let path = try!( - id.clone() - .into_pathbuf() - .map_err_into(GHEK::StoreIdHandlingError) - .map_into_hook_error() - ); - - let action = StoreAction::Create; - try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); - - let cfg = try!(self.runtime.config_value_or_err(&action)); - let repo = try!(self.runtime.repository(&action)); - let mut index = try!(fetch_index(repo, &action)); - - let file_status = try!( - repo - .status_file(&path) - .map_err_into(GHEK::RepositoryFileStatusError) - .map_into_hook_error() - ); - - let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { - if file_status.contains(STATUS_WT_MODIFIED) || - file_status.contains(STATUS_WT_NEW) { - - debug!("[GIT CREATE HOOK]: File is new or modified: {}", path.display()); - 0 - } else { - debug!("[GIT CREATE HOOK]: Ignoring file: {}", path.display()); - 1 - } - }; - - try!( - index.add_all(&[path], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) - .map_err_into(GHEK::RepositoryPathAddingError) - .map_into_hook_error() - ); - - index - .write() - .map_err_into(GHEK::RepositoryIndexWritingError) - .map_into_hook_error() + debug!("[GIT CREATE HOOK]: Doing nothing as Store::create() is lazy and does not write to disk"); + Ok(()) } } diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index fa4af2c9..7dd3a13c 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -1,4 +1,5 @@ use std::path::PathBuf; +use std::path::Path; use std::fmt::{Debug, Formatter, Error as FmtError}; use std::result::Result as RResult; @@ -88,6 +89,8 @@ impl StoreIdAccessor for UpdateHook { use vcs::git::config::commit_message; use vcs::git::error::MapIntoHookError; use vcs::git::util::fetch_index; + use git2::{Reference as GitReference, Repository, Error as Git2Error}; + use git2::{ADD_DEFAULT, STATUS_WT_NEW, STATUS_WT_MODIFIED, IndexMatchedPath}; debug!("[GIT UPDATE HOOK]: {:?}", id); @@ -96,6 +99,13 @@ impl StoreIdAccessor for UpdateHook { let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); + let path = try!( + id.clone() + .into_pathbuf() + .map_err_into(GHEK::StoreIdHandlingError) + .map_into_hook_error() + ); + let tree_id = try!( index.write_tree() .map_err_into(GHEK::RepositoryIndexWritingError) @@ -114,6 +124,29 @@ impl StoreIdAccessor for UpdateHook { .map_into_hook_error() ); + let file_status = try!( + repo + .status_file(&path) + .map_err_into(GHEK::RepositoryFileStatusError) + .map_into_hook_error() + ); + + let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { + if file_status.contains(STATUS_WT_NEW) || file_status.contains(STATUS_WT_MODIFIED) { + debug!("[GIT CREATE HOOK]: File is modified/new: {}", path.display()); + 0 + } else { + debug!("[GIT CREATE HOOK]: Ignoring file: {}", path.display()); + 1 + } + }; + + try!( + index.add_all(&[path], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) + .map_err_into(GHEK::RepositoryPathAddingError) + .map_into_hook_error() + ); + let mut parents = Vec::new(); { let commit = try!( From 3252f9b751e0ac8034f4d06aa5c6b01e73ffcfc5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 09:44:35 +0200 Subject: [PATCH 097/239] Move Update-Hook execution into Store._update() --- libimagstore/src/store.rs | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 7780c850..6d58b531 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -493,21 +493,10 @@ impl Store { /// Return the `FileLockEntry` and write to disk pub fn update<'a>(&'a self, mut entry: FileLockEntry<'a>) -> Result<()> { - if let Err(e) = self.execute_hooks_for_mut_file(self.pre_update_aspects.clone(), &mut entry) { - return Err(e) - .map_err_into(SEK::PreHookExecuteError) - .map_err_into(SEK::HookExecutionError) - .map_err_into(SEK::UpdateCallError); - } - - if let Err(e) = self._update(&entry) { + if let Err(e) = self._update(&mut entry) { return Err(e).map_err_into(SEK::UpdateCallError); } - - self.execute_hooks_for_mut_file(self.post_update_aspects.clone(), &mut entry) - .map_err_into(SEK::PostHookExecuteError) - .map_err_into(SEK::HookExecutionError) - .map_err_into(SEK::UpdateCallError) + Ok(()) } /// Internal method to write to the filesystem store. @@ -515,7 +504,14 @@ impl Store { /// # Assumptions /// This method assumes that entry is dropped _right after_ the call, hence /// it is not public. - fn _update<'a>(&'a self, entry: &FileLockEntry<'a>) -> Result<()> { + fn _update<'a>(&'a self, entry: &mut FileLockEntry<'a>) -> Result<()> { + if let Err(e) = self.execute_hooks_for_mut_file(self.pre_update_aspects.clone(), entry) { + return Err(e) + .map_err_into(SEK::PreHookExecuteError) + .map_err_into(SEK::HookExecutionError) + .map_err_into(SEK::UpdateCallError); + } + let mut hsmap = match self.entries.write() { Err(_) => return Err(SE::new(SEK::LockPoisoned, None)), Ok(e) => e, @@ -532,7 +528,11 @@ impl Store { try!(se.write_entry(&entry.entry)); se.status = StoreEntryStatus::Present; - Ok(()) + + self.execute_hooks_for_mut_file(self.post_update_aspects.clone(), entry) + .map_err_into(SEK::PostHookExecuteError) + .map_err_into(SEK::HookExecutionError) + .map_err_into(SEK::UpdateCallError) } /// Retrieve a copy of a given entry, this cannot be used to mutate @@ -865,7 +865,7 @@ impl<'a> DerefMut for FileLockEntry<'a> { impl<'a> Drop for FileLockEntry<'a> { /// This will silently ignore errors, use `Store::update` if you want to catch the errors fn drop(&mut self) { - let _ = self.store._update(self); + let _ = self.store._update(self).map_err(|e| trace_error(&e)); } } From a4231ac5d83d5abd3c166f2d481d609313f0478c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 09:54:06 +0200 Subject: [PATCH 098/239] Add debug output in UpdateHook::access() --- libimagstorestdhook/src/vcs/git/update.rs | 33 +++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 7dd3a13c..e36b7802 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -103,30 +103,29 @@ impl StoreIdAccessor for UpdateHook { id.clone() .into_pathbuf() .map_err_into(GHEK::StoreIdHandlingError) + .map_dbg_err_str("Failed to StoreId.into_pathbuf()") .map_into_hook_error() ); - let tree_id = try!( - index.write_tree() - .map_err_into(GHEK::RepositoryIndexWritingError) - .map_into_hook_error() - ); - let signature = try!( repo.signature() .map_err_into(GHEK::MkSignature) + .map_dbg_err_str("Failed to fetch signature") .map_into_hook_error() ); let head = try!( repo.head() .map_err_into(GHEK::HeadFetchError) + .map_dbg_err_str("Failed to fetch HEAD") .map_into_hook_error() ); let file_status = try!( repo .status_file(&path) + .map_dbg_err_str("Failed to fetch file status") + .map_dbg_err(|e| format!("\t-> {:?}", e)) .map_err_into(GHEK::RepositoryFileStatusError) .map_into_hook_error() ); @@ -144,6 +143,7 @@ impl StoreIdAccessor for UpdateHook { try!( index.add_all(&[path], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) .map_err_into(GHEK::RepositoryPathAddingError) + .map_dbg_err_str("Failed to add to index") .map_into_hook_error() ); @@ -152,6 +152,7 @@ impl StoreIdAccessor for UpdateHook { let commit = try!( repo.find_commit(head.target().unwrap()) .map_err_into(GHEK::RepositoryParentFetchingError) + .map_dbg_err_str("Failed to find commit HEAD") .map_into_hook_error() ); parents.push(commit); @@ -160,19 +161,29 @@ impl StoreIdAccessor for UpdateHook { // for converting from Vec to Vec<&Commit> let parents = parents.iter().collect::>(); - let tree = try!( - repo.find_tree(tree_id) - .map_err_into(GHEK::RepositoryParentFetchingError) + let tree_id = try!( + index.write_tree() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_dbg_err_str("Failed to write tree") .map_into_hook_error() ); - let message = try!(commit_message(cfg, StoreAction::Update)); + + let tree = try!( + repo.find_tree(tree_id) + .map_err_into(GHEK::RepositoryParentFetchingError) + .map_dbg_err_str("Failed to find tree") + .map_into_hook_error() + ); + + let message = try!(commit_message(cfg, StoreAction::Update) + .map_dbg_err_str("Failed to get commit message")); repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) + .map_dbg_err_str("Failed to commit") .map_err_into(GHEK::RepositoryCommittingError) .map_into_hook_error() .map(|_| ()) - } } From 0cfeda8652f48ec38f30e62f78eb5eead3da1601 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 10:40:35 +0200 Subject: [PATCH 099/239] We only need to pass the local part to git2 here --- libimagstorestdhook/src/vcs/git/update.rs | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index e36b7802..1381911d 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -99,14 +99,6 @@ impl StoreIdAccessor for UpdateHook { let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); - let path = try!( - id.clone() - .into_pathbuf() - .map_err_into(GHEK::StoreIdHandlingError) - .map_dbg_err_str("Failed to StoreId.into_pathbuf()") - .map_into_hook_error() - ); - let signature = try!( repo.signature() .map_err_into(GHEK::MkSignature) @@ -123,7 +115,7 @@ impl StoreIdAccessor for UpdateHook { let file_status = try!( repo - .status_file(&path) + .status_file(id.local()) .map_dbg_err_str("Failed to fetch file status") .map_dbg_err(|e| format!("\t-> {:?}", e)) .map_err_into(GHEK::RepositoryFileStatusError) @@ -141,7 +133,7 @@ impl StoreIdAccessor for UpdateHook { }; try!( - index.add_all(&[path], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) + index.add_all(&[id.local()], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) .map_err_into(GHEK::RepositoryPathAddingError) .map_dbg_err_str("Failed to add to index") .map_into_hook_error() From 0366d0f8cb381e77f6f87d8a5076fdd6bc187382 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 10:44:17 +0200 Subject: [PATCH 100/239] Add some debug output if commit worked --- libimagstorestdhook/src/vcs/git/update.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 1381911d..32ee18a4 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -172,6 +172,7 @@ impl StoreIdAccessor for UpdateHook { .map_dbg_err_str("Failed to get commit message")); repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) + .map_dbg_str("Committed") .map_dbg_err_str("Failed to commit") .map_err_into(GHEK::RepositoryCommittingError) .map_into_hook_error() From bee4c2002d387c34b22bac886bd67ad4fd1c1bb8 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 10:46:54 +0200 Subject: [PATCH 101/239] Write the tree before finding the parent commits --- libimagstorestdhook/src/vcs/git/update.rs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 32ee18a4..b02548ac 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -139,6 +139,13 @@ impl StoreIdAccessor for UpdateHook { .map_into_hook_error() ); + let tree_id = try!( + index.write_tree() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_dbg_err_str("Failed to write tree") + .map_into_hook_error() + ); + let mut parents = Vec::new(); { let commit = try!( @@ -153,14 +160,6 @@ impl StoreIdAccessor for UpdateHook { // for converting from Vec to Vec<&Commit> let parents = parents.iter().collect::>(); - let tree_id = try!( - index.write_tree() - .map_err_into(GHEK::RepositoryIndexWritingError) - .map_dbg_err_str("Failed to write tree") - .map_into_hook_error() - ); - - let tree = try!( repo.find_tree(tree_id) .map_err_into(GHEK::RepositoryParentFetchingError) From 0dc2baaee2b04d9741c66637d0e3fec7f16333a5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 14:16:08 +0200 Subject: [PATCH 102/239] Write index after committing --- libimagstorestdhook/src/vcs/git/update.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index b02548ac..eec56dd2 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -170,11 +170,17 @@ impl StoreIdAccessor for UpdateHook { let message = try!(commit_message(cfg, StoreAction::Update) .map_dbg_err_str("Failed to get commit message")); - repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) + try!(repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) .map_dbg_str("Committed") .map_dbg_err_str("Failed to commit") .map_err_into(GHEK::RepositoryCommittingError) .map_into_hook_error() + ); + + index.write() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_dbg_err_str("Failed to write tree") + .map_into_hook_error() .map(|_| ()) } From e49050932aa5794d51fa4779c5ca2eb9de8d0b9d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 10:14:08 +0200 Subject: [PATCH 103/239] Fix missing parentheses in impl Debug for UpdateHook --- libimagstorestdhook/src/vcs/git/update.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index eec56dd2..fb270e40 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -46,7 +46,7 @@ impl UpdateHook { impl Debug for UpdateHook { fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { - write!(fmt, "UpdateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}", + write!(fmt, "UpdateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?})", self.storepath, (if self.runtime.has_repository() { "Some(_)" } else { "None" }), self.position, From 8f26b2083042adaa5716d085182dc33d4d1cf426 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 17:37:10 +0200 Subject: [PATCH 104/239] [CHERRY-PICK] Refactor edit_in_tmpfile() To offer variant where we can pass the editor as command. --- libimagentryedit/src/edit.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libimagentryedit/src/edit.rs b/libimagentryedit/src/edit.rs index cdf976a4..cc9bbc64 100644 --- a/libimagentryedit/src/edit.rs +++ b/libimagentryedit/src/edit.rs @@ -39,6 +39,10 @@ impl<'a> Edit for FileLockEntry<'a> { } pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> { + edit_in_tmpfile_with_command(rt.editor(), s) +} + +pub fn edit_in_tmpfile_with_command(cmd: Command, s: &mut String) -> Result<()> { use tempfile::NamedTempFile; use std::io::Seek; use std::io::Read; @@ -75,3 +79,4 @@ pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> { Err(EditErrorKind::InstantiateError.into()) } } + From ff5a4b46c7ef546a86eaa429bb39c59d8decfaff Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 15:06:56 +0200 Subject: [PATCH 105/239] Remove StoreId::is_file() --- libimagstore/src/storeid.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libimagstore/src/storeid.rs b/libimagstore/src/storeid.rs index a5c2c11e..b2cfc121 100644 --- a/libimagstore/src/storeid.rs +++ b/libimagstore/src/storeid.rs @@ -75,10 +75,6 @@ impl StoreId { self.clone().into_pathbuf().map(|pb| pb.exists()).unwrap_or(false) } - pub fn is_file(&self) -> bool { - true - } - pub fn to_str(&self) -> Result { if self.base.is_some() { let mut base = self.base.as_ref().cloned().unwrap(); From 636674b0592513deef8542bad8fd9272ea90da17 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 16:52:03 +0200 Subject: [PATCH 106/239] All StoreIds point to files, so this check does not make sense here --- libimagstorestdhook/src/linkverify.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/libimagstorestdhook/src/linkverify.rs b/libimagstorestdhook/src/linkverify.rs index 85551999..cf877526 100644 --- a/libimagstorestdhook/src/linkverify.rs +++ b/libimagstorestdhook/src/linkverify.rs @@ -55,8 +55,6 @@ impl NonMutableHookDataAccessor for LinkedEntriesExistHook { for link in links { if !link.exists() { warn!("File link does not exist: {:?} -> {:?}", fle.get_location(), link); - } else if !link.is_file() { - warn!("File link is not a file: {:?} -> {:?}", fle.get_location(), link); } } }) From 501d1f38a2099efcb9580ede596fdb74cb9f23a4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 17:37:10 +0200 Subject: [PATCH 107/239] Refactor edit_in_tmpfile() To offer variant where we can pass the editor as command. --- libimagentryedit/src/edit.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libimagentryedit/src/edit.rs b/libimagentryedit/src/edit.rs index cdf976a4..cc9bbc64 100644 --- a/libimagentryedit/src/edit.rs +++ b/libimagentryedit/src/edit.rs @@ -39,6 +39,10 @@ impl<'a> Edit for FileLockEntry<'a> { } pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> { + edit_in_tmpfile_with_command(rt.editor(), s) +} + +pub fn edit_in_tmpfile_with_command(cmd: Command, s: &mut String) -> Result<()> { use tempfile::NamedTempFile; use std::io::Seek; use std::io::Read; @@ -75,3 +79,4 @@ pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> { Err(EditErrorKind::InstantiateError.into()) } } + From 027fffb5b51d9c957741eab07889bc5aed50189b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 17:44:21 +0200 Subject: [PATCH 108/239] Move edit_entry_with_cmd() to libimagutil --- libimagentryedit/Cargo.toml | 4 ++- libimagentryedit/src/edit.rs | 54 ++++++++++------------------------- libimagentryedit/src/error.rs | 1 + libimagentryedit/src/lib.rs | 2 +- libimagutil/Cargo.toml | 1 + libimagutil/src/edit.rs | 36 +++++++++++++++++++++++ libimagutil/src/lib.rs | 2 ++ 7 files changed, 59 insertions(+), 41 deletions(-) create mode 100644 libimagutil/src/edit.rs diff --git a/libimagentryedit/Cargo.toml b/libimagentryedit/Cargo.toml index 0c79700e..076519fe 100644 --- a/libimagentryedit/Cargo.toml +++ b/libimagentryedit/Cargo.toml @@ -4,7 +4,6 @@ version = "0.2.0" authors = ["Matthias Beyer "] [dependencies] -tempfile = "2.1.1" [dependencies.libimagerror] path = "../libimagerror" @@ -15,3 +14,6 @@ path = "../libimagrt" [dependencies.libimagstore] path = "../libimagstore" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/libimagentryedit/src/edit.rs b/libimagentryedit/src/edit.rs index cc9bbc64..08e2bfb4 100644 --- a/libimagentryedit/src/edit.rs +++ b/libimagentryedit/src/edit.rs @@ -39,44 +39,20 @@ impl<'a> Edit for FileLockEntry<'a> { } pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> { - edit_in_tmpfile_with_command(rt.editor(), s) -} - -pub fn edit_in_tmpfile_with_command(cmd: Command, s: &mut String) -> Result<()> { - use tempfile::NamedTempFile; - use std::io::Seek; - use std::io::Read; - use std::io::SeekFrom; - use std::io::Write; - - let file = try!(NamedTempFile::new().map_err_into(EditErrorKind::IOError)); - let file_path = file.path(); - let mut file = try!(file.reopen().map_err_into(EditErrorKind::IOError)); - - try!(file.write_all(&s.clone().into_bytes()[..]).map_err_into(EditErrorKind::IOError)); - try!(file.sync_data().map_err_into(EditErrorKind::IOError)); - - if let Some(mut editor) = rt.editor() { - let exit_status = editor.arg(file_path).status(); - - match exit_status.map(|s| s.success()).map_err(Box::new) { - Ok(true) => { - file.sync_data() - .and_then(|_| file.seek(SeekFrom::Start(0))) - .and_then(|_| { - let mut new_s = String::new(); - let res = file.read_to_string(&mut new_s); - *s = new_s; - res - }) - .map(|_| ()) - .map_err_into(EditErrorKind::IOError) - }, - Ok(false) => Err(EditErrorKind::ProcessExitFailure.into()), - Err(e) => Err(EditErrorKind::IOError.into_error_with_cause(e)), - } - } else { - Err(EditErrorKind::InstantiateError.into()) - } + use libimagutil::edit::edit_in_tmpfile_with_command; + + rt.editor() + .ok_or(EditErrorKind::NoEditor.into_error()) + .and_then(|editor| { + edit_in_tmpfile_with_command(editor, s) + .map_err_into(EditErrorKind::IOError) + .and_then(|worked| { + if !worked { + Err(EditErrorKind::ProcessExitFailure.into()) + } else { + Ok(()) + } + }) + }) } diff --git a/libimagentryedit/src/error.rs b/libimagentryedit/src/error.rs index 0cd675e0..776a51fb 100644 --- a/libimagentryedit/src/error.rs +++ b/libimagentryedit/src/error.rs @@ -1,6 +1,7 @@ generate_error_module!( generate_error_types!(EditError, EditErrorKind, IOError => "IO Error", + NoEditor => "No editor set", ProcessExitFailure => "Process did not exit properly", InstantiateError => "Instantation error" ); diff --git a/libimagentryedit/src/lib.rs b/libimagentryedit/src/lib.rs index 62cff1e4..d0a26038 100644 --- a/libimagentryedit/src/lib.rs +++ b/libimagentryedit/src/lib.rs @@ -1,7 +1,7 @@ #[macro_use] extern crate libimagerror; extern crate libimagstore; extern crate libimagrt; -extern crate tempfile; +extern crate libimagutil; pub mod edit; pub mod error; diff --git a/libimagutil/Cargo.toml b/libimagutil/Cargo.toml index 53e0e0ee..87be5306 100644 --- a/libimagutil/Cargo.toml +++ b/libimagutil/Cargo.toml @@ -7,4 +7,5 @@ authors = ["Matthias Beyer "] lazy_static = "0.1.15" log = "0.3" regex = "0.1" +tempfile = "2.1.1" diff --git a/libimagutil/src/edit.rs b/libimagutil/src/edit.rs new file mode 100644 index 00000000..ad23b6ed --- /dev/null +++ b/libimagutil/src/edit.rs @@ -0,0 +1,36 @@ +use std::io::Read; +use std::io::Seek; +use std::io::SeekFrom; +use std::io::Write; +use std::process::Command; +use std::io::Error as IOError; + +use tempfile::NamedTempFile; + +pub fn edit_in_tmpfile_with_command(mut cmd: Command, s: &mut String) -> Result { + let file = try!(NamedTempFile::new()); + let file_path = file.path(); + let mut file = try!(file.reopen()); + + try!(file.write_all(&s.clone().into_bytes()[..])); + try!(file.sync_data()); + + cmd.arg(file_path) + .status() + .and_then(|status| { + if status.success() { + file.sync_data() + .and_then(|_| file.seek(SeekFrom::Start(0))) + .and_then(|_| { + let mut new_s = String::new(); + let res = file.read_to_string(&mut new_s); + *s = new_s; + res + }) + .map(|_| true) + } else { + Ok(false) + } + }) +} + diff --git a/libimagutil/src/lib.rs b/libimagutil/src/lib.rs index 16183e7b..c0026c6f 100644 --- a/libimagutil/src/lib.rs +++ b/libimagutil/src/lib.rs @@ -16,9 +16,11 @@ #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; extern crate regex; +extern crate tempfile; #[macro_use] mod log_result; pub mod debug_result; +pub mod edit; pub mod info_result; pub mod ismatch; pub mod iter; From 05d38bdf4920c46fd86278761a2ff27d6d8b781b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 17:44:21 +0200 Subject: [PATCH 109/239] [CHERRY-PICK] Move edit_entry_with_cmd() to libimagutil --- libimagentryedit/Cargo.toml | 4 ++- libimagentryedit/src/edit.rs | 54 ++++++++++------------------------- libimagentryedit/src/error.rs | 1 + libimagentryedit/src/lib.rs | 2 +- libimagutil/Cargo.toml | 1 + libimagutil/src/edit.rs | 36 +++++++++++++++++++++++ libimagutil/src/lib.rs | 2 ++ 7 files changed, 59 insertions(+), 41 deletions(-) create mode 100644 libimagutil/src/edit.rs diff --git a/libimagentryedit/Cargo.toml b/libimagentryedit/Cargo.toml index 0c79700e..076519fe 100644 --- a/libimagentryedit/Cargo.toml +++ b/libimagentryedit/Cargo.toml @@ -4,7 +4,6 @@ version = "0.2.0" authors = ["Matthias Beyer "] [dependencies] -tempfile = "2.1.1" [dependencies.libimagerror] path = "../libimagerror" @@ -15,3 +14,6 @@ path = "../libimagrt" [dependencies.libimagstore] path = "../libimagstore" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/libimagentryedit/src/edit.rs b/libimagentryedit/src/edit.rs index cc9bbc64..08e2bfb4 100644 --- a/libimagentryedit/src/edit.rs +++ b/libimagentryedit/src/edit.rs @@ -39,44 +39,20 @@ impl<'a> Edit for FileLockEntry<'a> { } pub fn edit_in_tmpfile(rt: &Runtime, s: &mut String) -> Result<()> { - edit_in_tmpfile_with_command(rt.editor(), s) -} - -pub fn edit_in_tmpfile_with_command(cmd: Command, s: &mut String) -> Result<()> { - use tempfile::NamedTempFile; - use std::io::Seek; - use std::io::Read; - use std::io::SeekFrom; - use std::io::Write; - - let file = try!(NamedTempFile::new().map_err_into(EditErrorKind::IOError)); - let file_path = file.path(); - let mut file = try!(file.reopen().map_err_into(EditErrorKind::IOError)); - - try!(file.write_all(&s.clone().into_bytes()[..]).map_err_into(EditErrorKind::IOError)); - try!(file.sync_data().map_err_into(EditErrorKind::IOError)); - - if let Some(mut editor) = rt.editor() { - let exit_status = editor.arg(file_path).status(); - - match exit_status.map(|s| s.success()).map_err(Box::new) { - Ok(true) => { - file.sync_data() - .and_then(|_| file.seek(SeekFrom::Start(0))) - .and_then(|_| { - let mut new_s = String::new(); - let res = file.read_to_string(&mut new_s); - *s = new_s; - res - }) - .map(|_| ()) - .map_err_into(EditErrorKind::IOError) - }, - Ok(false) => Err(EditErrorKind::ProcessExitFailure.into()), - Err(e) => Err(EditErrorKind::IOError.into_error_with_cause(e)), - } - } else { - Err(EditErrorKind::InstantiateError.into()) - } + use libimagutil::edit::edit_in_tmpfile_with_command; + + rt.editor() + .ok_or(EditErrorKind::NoEditor.into_error()) + .and_then(|editor| { + edit_in_tmpfile_with_command(editor, s) + .map_err_into(EditErrorKind::IOError) + .and_then(|worked| { + if !worked { + Err(EditErrorKind::ProcessExitFailure.into()) + } else { + Ok(()) + } + }) + }) } diff --git a/libimagentryedit/src/error.rs b/libimagentryedit/src/error.rs index 0cd675e0..776a51fb 100644 --- a/libimagentryedit/src/error.rs +++ b/libimagentryedit/src/error.rs @@ -1,6 +1,7 @@ generate_error_module!( generate_error_types!(EditError, EditErrorKind, IOError => "IO Error", + NoEditor => "No editor set", ProcessExitFailure => "Process did not exit properly", InstantiateError => "Instantation error" ); diff --git a/libimagentryedit/src/lib.rs b/libimagentryedit/src/lib.rs index 62cff1e4..d0a26038 100644 --- a/libimagentryedit/src/lib.rs +++ b/libimagentryedit/src/lib.rs @@ -1,7 +1,7 @@ #[macro_use] extern crate libimagerror; extern crate libimagstore; extern crate libimagrt; -extern crate tempfile; +extern crate libimagutil; pub mod edit; pub mod error; diff --git a/libimagutil/Cargo.toml b/libimagutil/Cargo.toml index 53e0e0ee..87be5306 100644 --- a/libimagutil/Cargo.toml +++ b/libimagutil/Cargo.toml @@ -7,4 +7,5 @@ authors = ["Matthias Beyer "] lazy_static = "0.1.15" log = "0.3" regex = "0.1" +tempfile = "2.1.1" diff --git a/libimagutil/src/edit.rs b/libimagutil/src/edit.rs new file mode 100644 index 00000000..ad23b6ed --- /dev/null +++ b/libimagutil/src/edit.rs @@ -0,0 +1,36 @@ +use std::io::Read; +use std::io::Seek; +use std::io::SeekFrom; +use std::io::Write; +use std::process::Command; +use std::io::Error as IOError; + +use tempfile::NamedTempFile; + +pub fn edit_in_tmpfile_with_command(mut cmd: Command, s: &mut String) -> Result { + let file = try!(NamedTempFile::new()); + let file_path = file.path(); + let mut file = try!(file.reopen()); + + try!(file.write_all(&s.clone().into_bytes()[..])); + try!(file.sync_data()); + + cmd.arg(file_path) + .status() + .and_then(|status| { + if status.success() { + file.sync_data() + .and_then(|_| file.seek(SeekFrom::Start(0))) + .and_then(|_| { + let mut new_s = String::new(); + let res = file.read_to_string(&mut new_s); + *s = new_s; + res + }) + .map(|_| true) + } else { + Ok(false) + } + }) +} + diff --git a/libimagutil/src/lib.rs b/libimagutil/src/lib.rs index 16183e7b..c0026c6f 100644 --- a/libimagutil/src/lib.rs +++ b/libimagutil/src/lib.rs @@ -16,9 +16,11 @@ #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; extern crate regex; +extern crate tempfile; #[macro_use] mod log_result; pub mod debug_result; +pub mod edit; pub mod info_result; pub mod ismatch; pub mod iter; From 17805a0f1ed63fad8e8d53a58a11986aace624e1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 17:09:10 +0200 Subject: [PATCH 110/239] Add default settings for committing in the update hook --- imagrc.toml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/imagrc.toml b/imagrc.toml index 69142ce2..ac323962 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -94,3 +94,17 @@ ensure_branch = "master" # Try to checkout the ensure_branch if it isn't checked out try_checkout_ensure_branch = true +# Commit configuration +[store.hooks.stdhook_git_update.commit] + +# Whether to do the commit interactively +interactive = false + +# Set to true to use the $EDITOR for the commit, to false to do on commandline +# When committing without editor, only a single line is allowed as commit +# message +interactive_editor = false + +# Commit message if the commit is not interactive +message = "Update" + From 47c3d0e483c94030ddd60c05986e3453bd7b9ce6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 17:09:24 +0200 Subject: [PATCH 111/239] Implement commit_message() --- libimagstorestdhook/src/vcs/git/config.rs | 68 +++++++++++++++++++++-- 1 file changed, 63 insertions(+), 5 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index a7e262d6..84362563 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -9,15 +9,73 @@ use vcs::git::result::Result; use vcs::git::action::StoreAction; pub fn commit_interactive(config: &Value) -> bool { - warn!("Interactive committing not yet supported, using dummy commit message"); - false + match config.lookup("commit.interactive") { + Some(&Value::Boolean(b)) => b, + Some(_) => { + warn!("Configuration error, 'store.hooks.stdhook_git_update.commit.interactive' must be a Boolean."); + warn!("Defaulting to commit.interactive = false"); + false + } + None => { + warn!("Unavailable configuration for"); + warn!("\t'store.hooks.stdhook_git_update.commit.interactive'"); + warn!("Defaulting to false"); + false + } + } } -pub fn commit_message(config: &Value, action: StoreAction) -> Result { +fn commit_with_editor(config: &Value) -> bool { + match config.lookup("commit.interactive_editor") { + Some(&Value::Boolean(b)) => b, + Some(_) => { + warn!("Configuration error, 'store.hooks.stdhook_git_update.commit.interactive_editor' must be a Boolean."); + warn!("Defaulting to commit.interactive_editor = false"); + false + } + None => { + warn!("Unavailable configuration for"); + warn!("\t'store.hooks.stdhook_git_update.commit.interactive_editor'"); + warn!("Defaulting to false"); + false + } + } +} + +fn commit_default_msg<'a>(config: &'a Value) -> &'a str { + match config.lookup("commit.message") { + Some(&Value::String(ref b)) => b, + Some(_) => { + warn!("Configuration error, 'store.hooks.stdhook_git_update.commit.message' must be a String."); + warn!("Defaulting to commit.message = 'Update'"); + "Update" + } + None => { + warn!("Unavailable configuration for"); + warn!("\t'store.hooks.stdhook_git_update.commit.message'"); + warn!("Defaulting to commit.message = 'Update'"); + "Update" + } + } +} + +fn commit_template() -> &'static str { + "Commit template" +} + +pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction) -> Result { + use libimaginteraction::ask::ask_string; + use libimagutil::edit::edit_in_tmpfile_with_command; + use std::process::Command; + if commit_interactive(config) { - unimplemented!() + if commit_with_editor(config) { + unimplemented!() + } else { + unimplemented!() + } } else { - Ok(String::from("Dummy commit")) + Ok(String::from(commit_default_msg(config))) } } From 66d8b71bdfd81b5499379a915f166faa744f31ac Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 17:14:49 +0200 Subject: [PATCH 112/239] Add dep: libimaginteraction --- libimagstorestdhook/Cargo.toml | 3 +++ libimagstorestdhook/src/lib.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/libimagstorestdhook/Cargo.toml b/libimagstorestdhook/Cargo.toml index cd1eeeb4..912079b2 100644 --- a/libimagstorestdhook/Cargo.toml +++ b/libimagstorestdhook/Cargo.toml @@ -15,6 +15,9 @@ path = "../libimagstore" [dependencies.libimagentrylink] path = "../libimagentrylink" +[dependencies.libimaginteraction] +path = "../libimaginteraction" + [dependencies.libimagerror] path = "../libimagerror" diff --git a/libimagstorestdhook/src/lib.rs b/libimagstorestdhook/src/lib.rs index a99ff515..76b15b7e 100644 --- a/libimagstorestdhook/src/lib.rs +++ b/libimagstorestdhook/src/lib.rs @@ -21,6 +21,7 @@ extern crate git2; extern crate libimagstore; extern crate libimagentrylink; +extern crate libimaginteraction; #[macro_use] extern crate libimagerror; extern crate libimagutil; From 995593a3b7abefa150074f960caf32783e6a30ed Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 17:19:24 +0200 Subject: [PATCH 113/239] Add string input --- libimagstorestdhook/src/vcs/git/config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 84362563..67f2335d 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -72,7 +72,7 @@ pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction) -> if commit_with_editor(config) { unimplemented!() } else { - unimplemented!() + Ok(ask_string("Commit Message", None, false, false, None, "> ")) } } else { Ok(String::from(commit_default_msg(config))) From cc035525ec96bc418ddfd68b64043939f1d5e359 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 17:38:54 +0200 Subject: [PATCH 114/239] Add error kinds for editor calling --- libimagstorestdhook/src/vcs/git/error.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index a8a00e14..d63c792e 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -32,7 +32,12 @@ generate_error_module!( StoreIdHandlingError => "Error handling the store id object", StoreIdStripError => "Couldn't strip prefix from StoreID object", - RepositoryFileStatusError => "Error while getting file status" + RepositoryFileStatusError => "Error while getting file status", + + GitConfigFetchError => "Error fetching git config", + GitConfigEditorFetchError => "Error fetching 'editor' from git config", + CommitEditorInstantiationError => "Error when trying to instantiate commit editor", + EditorError => "Error while calling editor" ); ); From 4b281dddc9abcf3e62e69d8312fdb46a5468d372 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 8 Sep 2016 17:39:32 +0200 Subject: [PATCH 115/239] Implement editor calling --- libimagstorestdhook/src/vcs/git/config.rs | 14 +++++++++++++- libimagstorestdhook/src/vcs/git/update.rs | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 67f2335d..95e09a42 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -1,6 +1,7 @@ use toml::Value; use libimagerror::into::IntoError; +use libimagutil::edit::edit_in_tmpfile_with_command; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; @@ -8,6 +9,8 @@ use vcs::git::result::Result; use vcs::git::action::StoreAction; +use git2::Repository; + pub fn commit_interactive(config: &Value) -> bool { match config.lookup("commit.interactive") { Some(&Value::Boolean(b)) => b, @@ -70,7 +73,16 @@ pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction) -> if commit_interactive(config) { if commit_with_editor(config) { - unimplemented!() + repo.config() + .map_err_into(GHEK::GitConfigFetchError) + .and_then(|c| c.get_string("core.editor").map_err_into(GHEK::GitConfigEditorFetchError)) + .map_err_into(GHEK::ConfigError) + .map(Command::new) + .and_then(|cmd| { + let mut s = String::from(commit_template()); + edit_in_tmpfile_with_command(cmd, &mut s).map(|_| s) + .map_err_into(GHEK::EditorError) + }) } else { Ok(ask_string("Commit Message", None, false, false, None, "> ")) } diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index fb270e40..2dce8ab2 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -167,7 +167,7 @@ impl StoreIdAccessor for UpdateHook { .map_into_hook_error() ); - let message = try!(commit_message(cfg, StoreAction::Update) + let message = try!(commit_message(&repo, cfg, StoreAction::Update) .map_dbg_err_str("Failed to get commit message")); try!(repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) From 41c7cd2363f660d9bae900727e38b17baabc63d5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 9 Sep 2016 11:48:10 +0200 Subject: [PATCH 116/239] [CHERRY-PICK] Add newline before header The lastest release of the `toml-rs` crate (2.1) removes leading spaces before arrays and tables, causing our tests to fail. This fixes it. --- libimagstore/src/store.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 6d58b531..5922b35f 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -1440,7 +1440,7 @@ impl Entry { } pub fn to_str(&self) -> String { - format!("---{header}---\n{content}", + format!("---\n{header}---\n{content}", header = ::toml::encode_str(&self.header.header), content = self.content) } From 797ea9e8526e27f6b79f64275d750cd3e3e60535 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 9 Sep 2016 17:07:29 +0200 Subject: [PATCH 117/239] travis: Use makefile for building things --- .travis.yml | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/.travis.yml b/.travis.yml index 94325312..77478906 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,49 +20,29 @@ before_script: export PATH=$HOME/.local/bin:$PATH script: - | - travis_cargo_run_in() { - echo ":: Trying to run cargo in $1" - [[ -d "$1" ]] && - cd "$1" && - { - { - if [[ $(echo "$1" | grep lib) ]]; then - travis-cargo -q test - else - travis-cargo -q build - fi - } && - cd - - } || exit 1 - } - - run_sh_test() { - echo "--- Running test script: '$1'" - bash $1 || { echo "--- Test failed. Exiting"; exit 1; } - echo "--- Test script $1 executed successfully" - } - - echo "<< Changes in ./doc are not build by CI >>" - + libs_to_test="$(find . -maxdepth 1 name "libimag*" -printf "test-%f ")" + bins_to_build="$(find . -maxdepth 1 name "imag-*" -printf "%f ")" + make $libs_to_test && \ + make $bins_to_build && \ for d in $(find -name "Cargo.toml" | grep -vE "^./Cargo.toml$"); do - echo ":: Working on $d" dir=$(dirname $d) { \ - echo -e "\n--- Running in $d ---\n" && \ - travis_cargo_run_in $dir && \ - echo "--- Running test scripts ---" && \ - for testsh in $(find $dir -iname "*test.sh"); do - run_sh_test $testsh - done && \ - echo -e "--- Done with test scripts ---\n\n" + echo "--- Running test scripts ---" && \ + for testsh in $(find $dir -iname "*test.sh"); do + echo "--- Running test script: '$1'" + bash $1 || { echo "--- Test failed. Exiting"; exit 1; } + echo "--- Test script $1 executed successfully" + done && \ } || true done + addons: apt: packages: - libcurl4-openssl-dev - - libelf-dev - libdw-dev + - libelf-dev + - make after_success: - | pushd .imag-documentation && From 931845105bc8f810657774adbf47546b125947be Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 7 Sep 2016 22:08:27 +0200 Subject: [PATCH 118/239] runtime: Remove unused import Signature --- libimagstorestdhook/src/vcs/git/runtime.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 13902b7d..7cefc9bf 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use git2::{Repository, Signature}; +use git2::Repository; use toml::Value; use libimagerror::into::IntoError; From 7f4108ad8567e64e7d67d23e53ed9f75f1cce093 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 10 Sep 2016 17:11:45 +0200 Subject: [PATCH 119/239] Remove unused imports: create hook --- libimagstorestdhook/src/vcs/git/create.rs | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs index 335bf2a6..431fbd36 100644 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ b/libimagstorestdhook/src/vcs/git/create.rs @@ -1,30 +1,17 @@ use std::path::PathBuf; -use std::path::Path; use std::fmt::{Debug, Formatter, Error as FmtError}; use std::result::Result as RResult; use toml::Value; -use git2::{Reference as GitReference, Repository, Error as Git2Error}; -use git2::{ADD_DEFAULT, STATUS_WT_NEW, STATUS_WT_MODIFIED, IndexMatchedPath}; use libimagstore::storeid::StoreId; use libimagstore::hook::Hook; -use libimagstore::hook::error::HookError as HE; -use libimagstore::hook::error::HookErrorKind as HEK; -use libimagstore::hook::error::CustomData as HECD; use libimagstore::hook::result::HookResult; use libimagstore::hook::position::HookPosition; use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; use libimagerror::trace::trace_error; -use libimagerror::into::IntoError; -use libimagutil::debug_result::*; -use vcs::git::result::Result; -use vcs::git::error::MapIntoHookError; -use vcs::git::error::MapErrInto; -use vcs::git::error::GitHookErrorKind as GHEK; -use vcs::git::error::GitHookError as GHE; use vcs::git::runtime::Runtime as GRuntime; pub struct CreateHook { From 412c4b5a300d38207ef3399bbeb304e4f416dd24 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 10 Sep 2016 17:12:26 +0200 Subject: [PATCH 120/239] Remove unused import: config module --- libimagstorestdhook/src/vcs/git/config.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 95e09a42..d4ae10f7 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -1,7 +1,6 @@ use toml::Value; use libimagerror::into::IntoError; -use libimagutil::edit::edit_in_tmpfile_with_command; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; From 3cf6cc4506bb29850b135c065e1e0b371352c54a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 10 Sep 2016 17:13:35 +0200 Subject: [PATCH 121/239] Remove unused imports: Update hook --- libimagstorestdhook/src/vcs/git/update.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 2dce8ab2..1679e05b 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -5,23 +5,17 @@ use std::result::Result as RResult; use toml::Value; -use libimagerror::into::IntoError; use libimagerror::trace::trace_error; use libimagstore::hook::Hook; use libimagstore::hook::accessor::StoreIdAccessor; use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; -use libimagstore::hook::error::HookError as HE; -use libimagstore::hook::error::HookErrorKind as HEK; use libimagstore::hook::position::HookPosition; use libimagstore::hook::result::HookResult; use libimagstore::storeid::StoreId; use libimagutil::debug_result::*; -use vcs::git::error::GitHookError as GHE; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; -use vcs::git::error::MapIntoHookError; -use vcs::git::result::Result; use vcs::git::runtime::Runtime as GRuntime; pub struct UpdateHook { @@ -89,7 +83,6 @@ impl StoreIdAccessor for UpdateHook { use vcs::git::config::commit_message; use vcs::git::error::MapIntoHookError; use vcs::git::util::fetch_index; - use git2::{Reference as GitReference, Repository, Error as Git2Error}; use git2::{ADD_DEFAULT, STATUS_WT_NEW, STATUS_WT_MODIFIED, IndexMatchedPath}; debug!("[GIT UPDATE HOOK]: {:?}", id); From b1af5dc1d59d948ace17beee9fbcbe72da128276 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 10 Sep 2016 17:13:54 +0200 Subject: [PATCH 122/239] Remove unused imports: util module --- libimagstorestdhook/src/vcs/git/util.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index 56b66323..1e1dd03d 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -6,7 +6,6 @@ use git2::{Repository, Index}; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; -use vcs::git::runtime::Runtime as GRuntime; use vcs::git::action::StoreAction; use vcs::git::error::MapIntoHookError; From 32c6ab0aaa1eb554a541e0bb3767f6a885a6bddb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 15:06:30 +0200 Subject: [PATCH 123/239] Remove dead code: {Create,Retrieve}Hook implementation --- libimagstorestdhook/src/vcs/git/create.rs | 85 --------------------- libimagstorestdhook/src/vcs/git/mod.rs | 2 - libimagstorestdhook/src/vcs/git/retrieve.rs | 59 -------------- 3 files changed, 146 deletions(-) delete mode 100644 libimagstorestdhook/src/vcs/git/create.rs delete mode 100644 libimagstorestdhook/src/vcs/git/retrieve.rs diff --git a/libimagstorestdhook/src/vcs/git/create.rs b/libimagstorestdhook/src/vcs/git/create.rs deleted file mode 100644 index 431fbd36..00000000 --- a/libimagstorestdhook/src/vcs/git/create.rs +++ /dev/null @@ -1,85 +0,0 @@ -use std::path::PathBuf; -use std::fmt::{Debug, Formatter, Error as FmtError}; -use std::result::Result as RResult; - -use toml::Value; - -use libimagstore::storeid::StoreId; -use libimagstore::hook::Hook; -use libimagstore::hook::result::HookResult; -use libimagstore::hook::position::HookPosition; -use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; -use libimagstore::hook::accessor::StoreIdAccessor; -use libimagerror::trace::trace_error; - -use vcs::git::runtime::Runtime as GRuntime; - -pub struct CreateHook { - storepath: PathBuf, - - runtime: GRuntime, - - position: HookPosition, -} - -impl CreateHook { - - pub fn new(storepath: PathBuf, p: HookPosition) -> CreateHook { - CreateHook { - runtime: GRuntime::new(&storepath), - storepath: storepath, - position: p, - } - } - -} - -impl Debug for CreateHook { - - fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { - write!(fmt, "CreateHook(storepath={:?}, repository={}, pos={:?}, cfg={:?}", - self.storepath, - (if self.runtime.has_repository() { "Some(_)" } else { "None" }), - self.position, - self.runtime.has_config()) - } -} - -impl Hook for CreateHook { - - fn name(&self) -> &'static str { - "stdhook_git_create" - } - - fn set_config(&mut self, config: &Value) { - if let Err(e) = self.runtime.set_config(config) { - trace_error(&e); - } - } - -} - -impl HookDataAccessorProvider for CreateHook { - - fn accessor(&self) -> HookDataAccessor { - HookDataAccessor::StoreIdAccess(self) - } -} - -impl StoreIdAccessor for CreateHook { - - /// The implementation of the CreateHook - /// - /// # Scope - /// - /// What this function has to do is _adding_ the new entry to the git index. - /// After that, the UpdateHook will take care of committing the changes or new file. - /// - fn access(&self, id: &StoreId) -> HookResult<()> { - debug!("[GIT CREATE HOOK]: {:?}", id); - debug!("[GIT CREATE HOOK]: Doing nothing as Store::create() is lazy and does not write to disk"); - Ok(()) - } - -} - diff --git a/libimagstorestdhook/src/vcs/git/mod.rs b/libimagstorestdhook/src/vcs/git/mod.rs index ca9f5c61..e679e6df 100644 --- a/libimagstorestdhook/src/vcs/git/mod.rs +++ b/libimagstorestdhook/src/vcs/git/mod.rs @@ -1,11 +1,9 @@ mod action; mod config; -pub mod create; pub mod delete; mod error; mod result; mod runtime; -pub mod retrieve; pub mod update; pub mod util; diff --git a/libimagstorestdhook/src/vcs/git/retrieve.rs b/libimagstorestdhook/src/vcs/git/retrieve.rs deleted file mode 100644 index ca034812..00000000 --- a/libimagstorestdhook/src/vcs/git/retrieve.rs +++ /dev/null @@ -1,59 +0,0 @@ -use std::path::PathBuf; - -use toml::Value; - -use libimagstore::storeid::StoreId; -use libimagstore::hook::Hook; -use libimagstore::hook::result::HookResult; -use libimagstore::hook::position::HookPosition; -use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; -use libimagstore::hook::accessor::StoreIdAccessor; - -#[derive(Debug)] -pub struct RetrieveHook { - storepath: PathBuf, - - position: HookPosition, - config: Option, -} - -impl RetrieveHook { - - pub fn new(storepath: PathBuf, p: HookPosition) -> RetrieveHook { - RetrieveHook { - storepath: storepath, - position: p, - config: None, - } - } - -} - -impl Hook for RetrieveHook { - - fn name(&self) -> &'static str { - "stdhook_git_retrieve" - } - - fn set_config(&mut self, config: &Value) { - self.config = Some(config.clone()); - } - -} - -impl HookDataAccessorProvider for RetrieveHook { - - fn accessor(&self) -> HookDataAccessor { - HookDataAccessor::StoreIdAccess(self) - } -} - -impl StoreIdAccessor for RetrieveHook { - - fn access(&self, id: &StoreId) -> HookResult<()> { - debug!("[GIT RETRIEVE HOOK]: {:?}", id); - Ok(()) - } - -} - From 62ad1d807100116af786cbaa02cc93d5b4a1aa65 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 15:22:04 +0200 Subject: [PATCH 124/239] Add documentation for the StoreAction util type --- libimagstorestdhook/src/vcs/git/action.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/action.rs b/libimagstorestdhook/src/vcs/git/action.rs index 277260f0..fbfa3fe4 100644 --- a/libimagstorestdhook/src/vcs/git/action.rs +++ b/libimagstorestdhook/src/vcs/git/action.rs @@ -1,5 +1,6 @@ use std::fmt::{Display, Formatter, Error}; +/// Utility type to specify which kind of store action is running #[derive(Clone, Debug)] pub enum StoreAction { Create, From 9d47664cc2226309b464d5d569bb8e84d492fa57 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 15:22:13 +0200 Subject: [PATCH 125/239] Add documentation for the configuration utilities --- libimagstorestdhook/src/vcs/git/config.rs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index d4ae10f7..a75d99b1 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -10,6 +10,7 @@ use vcs::git::action::StoreAction; use git2::Repository; +/// Check the configuration whether we should commit interactively pub fn commit_interactive(config: &Value) -> bool { match config.lookup("commit.interactive") { Some(&Value::Boolean(b)) => b, @@ -27,6 +28,7 @@ pub fn commit_interactive(config: &Value) -> bool { } } +/// Check the configuration whether we should commit with the editor fn commit_with_editor(config: &Value) -> bool { match config.lookup("commit.interactive_editor") { Some(&Value::Boolean(b)) => b, @@ -44,6 +46,7 @@ fn commit_with_editor(config: &Value) -> bool { } } +/// Get the commit default message fn commit_default_msg<'a>(config: &'a Value) -> &'a str { match config.lookup("commit.message") { Some(&Value::String(ref b)) => b, @@ -61,10 +64,18 @@ fn commit_default_msg<'a>(config: &'a Value) -> &'a str { } } +/// Get the commit template +/// +/// TODO: Implement good template string fn commit_template() -> &'static str { "Commit template" } +/// Generate a commit message +/// +/// Uses the functions `commit_interactive()` and `commit_with_editor()` +/// or reads one from the commandline or uses the `commit_default_msg()` string to create a commit +/// message. pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction) -> Result { use libimaginteraction::ask::ask_string; use libimagutil::edit::edit_in_tmpfile_with_command; @@ -90,10 +101,15 @@ pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction) -> } } +/// Check whether the hook should abort if the repository cannot be initialized pub fn abort_on_repo_init_err(cfg: Option<&Value>) -> bool { get_bool_cfg(cfg, "abort_on_repo_init_failure", true, true) } +/// Get the branch which must be checked out before running the hook (if any). +/// +/// If there is no configuration for this, this is `Ok(None)`, otherwise we try to find the +/// configuration `String`. pub fn ensure_branch(cfg: Option<&Value>) -> Result> { match cfg { Some(cfg) => { @@ -114,10 +130,12 @@ pub fn ensure_branch(cfg: Option<&Value>) -> Result> { } } +/// Check whether we should check out a branch before committing. pub fn do_checkout_ensure_branch(cfg: Option<&Value>) -> bool { get_bool_cfg(cfg, "try_checkout_ensure_branch", true, true) } +/// Helper to get a boolean value from the configuration. fn get_bool_cfg(cfg: Option<&Value>, name: &str, on_fail: bool, on_unavail: bool) -> bool { cfg.map(|cfg| { match cfg.lookup(name) { From ffcdd46fe7a15f353b5f447ea2c962ed1410c8b3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 15:22:23 +0200 Subject: [PATCH 126/239] Add documentation for the Runtime utility --- libimagstorestdhook/src/vcs/git/runtime.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 7cefc9bf..5a48d5be 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -14,6 +14,9 @@ use vcs::git::action::StoreAction; use vcs::git::result::Result; use vcs::git::error::{MapErrInto, GitHookErrorKind as GHEK}; +/// Runtime object for git hook implementations. +/// +/// Contains some utility functionality to hold the repository and the configuration for the hooks. pub struct Runtime { repository: Option, config: Option, @@ -21,6 +24,11 @@ pub struct Runtime { impl Runtime { + /// Build a `Runtime` object, pass the store path to build the `Repository` instance the + /// `Runtime` has to contain. + /// + /// If the building of the `Repository` fails, this function `trace_error()`s the error and + /// returns a `Runtime` object that does _not_ contain a `Repository`. pub fn new(storepath: &PathBuf) -> Runtime { Runtime { repository: match Repository::open(storepath) { @@ -35,19 +43,27 @@ impl Runtime { } } + /// Set the configuration for the `Runtime`. Always returns `Ok(())`. pub fn set_config(&mut self, cfg: &Value) -> Result<()> { self.config = Some(cfg.clone()); Ok(()) } + /// Check whether the `Runtime` has a `Repository` pub fn has_repository(&self) -> bool { self.repository.is_some() } + /// Check whether the `Runtime` has a configuration pub fn has_config(&self) -> bool { self.config.is_some() } + /// Get the the config value by reference or get an `Err()` which can be returned to the callee + /// of the Hook. + /// + /// The `action` Argument is required in case of `Err()` so the error message can be build + /// correctly. pub fn config_value_or_err(&self, action: &StoreAction) -> HookResult<&Value> { self.config .as_ref() @@ -61,6 +77,11 @@ impl Runtime { }) } + /// Get the `Repository` object from the `Runtime` or an `Err()` that can be returned to the + /// callee of the Hook. + /// + /// The `action` Argument is required in case of `Err()` so the error message can be build + /// correctly. pub fn repository(&self, action: &StoreAction) -> HookResult<&Repository> { use vcs::git::error::MapIntoHookError; @@ -74,6 +95,7 @@ impl Runtime { .map_dbg(|_| format!("[GIT {} HOOK]: Repository object fetched", action.uppercase())) } + /// Ensure that the branch that is put in the configuration file is checked out, if any. pub fn ensure_cfg_branch_is_checked_out(&self, action: &StoreAction) -> HookResult<()> { use vcs::git::config::ensure_branch; From 610a59a8d6cc0462fc27639286cfd718839b8e4e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 15:22:33 +0200 Subject: [PATCH 127/239] Add documentation for the UpdateHook implementation --- libimagstorestdhook/src/vcs/git/update.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 1679e05b..70b37b49 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -18,6 +18,14 @@ use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; use vcs::git::runtime::Runtime as GRuntime; +/// The `UpdateHook` type +/// +/// Represents a hook which is executed whenever a entry in the store is updated (written to disk). +/// +/// # Time of execution +/// +/// This hook is executed _after_ the store operation succeeded, so _after_ the file is written to +/// disk. pub struct UpdateHook { storepath: PathBuf, @@ -54,6 +62,12 @@ impl Hook for UpdateHook { "stdhook_git_update" } + /// Set the configuration of the hook. See + /// `libimagstorestdhook::vcs::git::runtime::Runtime::set_config()`. + /// + /// This function traces the error (using `trace_error()`) that + /// `libimagstorestdhook::vcs::git::runtime::Runtime::set_config()` + /// returns, if any. fn set_config(&mut self, config: &Value) { if let Err(e) = self.runtime.set_config(config) { trace_error(&e); From 2a82762e9a5d1a42b0b7748ecc2d1ea5a0eb9153 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 15:28:04 +0200 Subject: [PATCH 128/239] Remove hook initialization from runtime setup for hooks that are removed by the latest commit --- libimagrt/src/runtime.rs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index 67d9950b..a942b261 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -43,9 +43,7 @@ impl<'a> Runtime<'a> { use libimagstore::hook::Hook; use libimagstore::error::StoreErrorKind; use libimagstorestdhook::debug::DebugHook; - use libimagstorestdhook::vcs::git::create::CreateHook as GitCreateHook; use libimagstorestdhook::vcs::git::delete::DeleteHook as GitDeleteHook; - use libimagstorestdhook::vcs::git::retrieve::RetrieveHook as GitRetrieveHook; use libimagstorestdhook::vcs::git::update::UpdateHook as GitUpdateHook; use libimagerror::trace::trace_error; use libimagerror::trace::trace_error_dbg; @@ -141,9 +139,7 @@ impl<'a> Runtime<'a> { let sp = storepath; let hooks : Vec<(Box, &str, HP)> = vec![ - (Box::new(GitCreateHook::new(sp.clone(), HP::PostCreate)) , "vcs", HP::PostCreate), (Box::new(GitDeleteHook::new(sp.clone(), HP::PreDelete)) , "vcs", HP::PreDelete), - (Box::new(GitRetrieveHook::new(sp.clone(), HP::PostRetrieve)), "vcs", HP::PostRetrieve), (Box::new(GitUpdateHook::new(sp, HP::PostUpdate)) , "vcs", HP::PostUpdate), ]; From 994d88e65d71f9b0a6c295a9eab81059dbc6ddb3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 17:23:23 +0200 Subject: [PATCH 129/239] DeleteHook: Use Runtime object internally for storing config --- libimagstorestdhook/src/vcs/git/delete.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index 902e5096..ccb38b4f 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -9,21 +9,26 @@ use libimagstore::hook::position::HookPosition; use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; +use vcs::git::error::GitHookErrorKind as GHEK; +use vcs::git::error::MapErrInto; +use vcs::git::runtime::Runtime as GRuntime; + #[derive(Debug)] pub struct DeleteHook { storepath: PathBuf, + runtime: GRuntime, + position: HookPosition, - config: Option, } impl DeleteHook { pub fn new(storepath: PathBuf, p: HookPosition) -> DeleteHook { DeleteHook { + runtime: GRuntime::new(&storepath), storepath: storepath, position: p, - config: None, } } @@ -35,8 +40,16 @@ impl Hook for DeleteHook { "stdhook_git_delete" } + /// Set the configuration of the hook. See + /// `libimagstorestdhook::vcs::git::runtime::Runtime::set_config()`. + /// + /// This function traces the error (using `trace_error()`) that + /// `libimagstorestdhook::vcs::git::runtime::Runtime::set_config()` + /// returns, if any. fn set_config(&mut self, config: &Value) { - self.config = Some(config.clone()); + if let Err(e) = self.runtime.set_config(config) { + trace_error(&e); + } } } From 47646d608b1f99ecbac586241e6fdae191bf2c97 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 17:23:34 +0200 Subject: [PATCH 130/239] Impl Debug for DeleteHook --- libimagstorestdhook/src/vcs/git/delete.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index ccb38b4f..e176a3db 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -13,7 +13,6 @@ use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; use vcs::git::runtime::Runtime as GRuntime; -#[derive(Debug)] pub struct DeleteHook { storepath: PathBuf, @@ -34,6 +33,17 @@ impl DeleteHook { } +impl Debug for DeleteHook { + fn fmt(&self, fmt: &mut Formatter) -> RResult<(), FmtError> { + write!(fmt, "DeleteHook(storepath={:?}, repository={}, pos={:?}, cfg={:?})", + self.storepath, + (if self.runtime.has_repository() { "Some(_)" } else { "None" }), + self.position, + self.runtime.has_config()) + } +} + + impl Hook for DeleteHook { fn name(&self) -> &'static str { From 721238ce144cdc344a09147243c2f32561e7f217 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 17:46:52 +0200 Subject: [PATCH 131/239] Add configuration for delete hook --- imagrc.toml | 42 ++++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/imagrc.toml b/imagrc.toml index ac323962..83f7e480 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -66,20 +66,6 @@ ensure_branch = "master" # Try to checkout the ensure_branch if it isn't checked out try_checkout_ensure_branch = true -[store.hooks.stdhook_git_delete] -aspect = "vcs" - -# Fail if the repository cannot be opened. If this is set to `false`, the error -# will be printed, but will not abort the store operation. `true` will print the -# error and abort the store action. -abort_on_repo_init_failure = true - -# Ensure to be on this branche before doing anything. -ensure_branch = "master" - -# Try to checkout the ensure_branch if it isn't checked out -try_checkout_ensure_branch = true - [store.hooks.stdhook_git_update] aspect = "vcs" @@ -108,3 +94,31 @@ interactive_editor = false # Commit message if the commit is not interactive message = "Update" +[store.hooks.stdhook_git_delete] +aspect = "vcs" + +# Fail if the repository cannot be opened. If this is set to `false`, the error +# will be printed, but will not abort the store operation. `true` will print the +# error and abort the store action. +abort_on_repo_init_failure = true + +# Ensure to be on this branche before doing anything. +ensure_branch = "master" + +# Try to checkout the ensure_branch if it isn't checked out +try_checkout_ensure_branch = true + +# Commit configuration +[store.hooks.stdhook_git_delete.commit] + +# Whether to do the commit interactively +interactive = false + +# Set to true to use the $EDITOR for the commit, to false to do on commandline +# When committing without editor, only a single line is allowed as commit +# message +interactive_editor = false + +# Commit message if the commit is not interactive +message = "Deleted" + From d90e74518532f33617df7f9d44e3e938c2912ea4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 17:47:07 +0200 Subject: [PATCH 132/239] Add implementation for delete hook --- libimagstorestdhook/src/vcs/git/delete.rs | 102 +++++++++++++++++++++- 1 file changed, 101 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index e176a3db..63e9f65c 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -1,13 +1,18 @@ use std::path::PathBuf; +use std::path::Path; +use std::fmt::{Debug, Formatter, Error as FmtError}; +use std::result::Result as RResult; use toml::Value; +use libimagerror::trace::trace_error; use libimagstore::storeid::StoreId; use libimagstore::hook::Hook; use libimagstore::hook::result::HookResult; use libimagstore::hook::position::HookPosition; use libimagstore::hook::accessor::{HookDataAccessor, HookDataAccessorProvider}; use libimagstore::hook::accessor::StoreIdAccessor; +use libimagutil::debug_result::*; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; @@ -74,8 +79,103 @@ impl HookDataAccessorProvider for DeleteHook { impl StoreIdAccessor for DeleteHook { fn access(&self, id: &StoreId) -> HookResult<()> { + use vcs::git::action::StoreAction; + use vcs::git::config::commit_message; + use vcs::git::error::MapIntoHookError; + use vcs::git::util::fetch_index; + use git2::{ADD_DEFAULT, STATUS_WT_DELETED, IndexMatchedPath}; + debug!("[GIT DELETE HOOK]: {:?}", id); - Ok(()) + + let action = StoreAction::Delete; + let cfg = try!(self.runtime.config_value_or_err(&action)); + let repo = try!(self.runtime.repository(&action)); + let mut index = try!(fetch_index(repo, &action)); + + let signature = try!( + repo.signature() + .map_err_into(GHEK::MkSignature) + .map_dbg_err_str("Failed to fetch signature") + .map_into_hook_error() + ); + + let head = try!( + repo.head() + .map_err_into(GHEK::HeadFetchError) + .map_dbg_err_str("Failed to fetch HEAD") + .map_into_hook_error() + ); + + let file_status = try!( + repo + .status_file(id.local()) + .map_dbg_err_str("Failed to fetch file status") + .map_dbg_err(|e| format!("\t-> {:?}", e)) + .map_err_into(GHEK::RepositoryFileStatusError) + .map_into_hook_error() + ); + + let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { + debug!("[GIT DELETE HOOK]: Checking file status for: {}", path.display()); + if file_status.contains(STATUS_WT_DELETED) { + debug!("[GIT DELETE HOOK]: File is deleted: {}", path.display()); + 0 + } else { + debug!("[GIT DELETE HOOK]: Ignoring file: {}", path.display()); + 1 + } + }; + + try!( + index.add_all(&[id.local()], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) + .map_err_into(GHEK::RepositoryPathAddingError) + .map_dbg_err_str("Failed to add to index") + .map_into_hook_error() + ); + + let tree_id = try!( + index.write_tree() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_dbg_err_str("Failed to write tree") + .map_into_hook_error() + ); + + let mut parents = Vec::new(); + { + let commit = try!( + repo.find_commit(head.target().unwrap()) + .map_err_into(GHEK::RepositoryParentFetchingError) + .map_dbg_err_str("Failed to find commit HEAD") + .map_into_hook_error() + ); + parents.push(commit); + } + + // for converting from Vec to Vec<&Commit> + let parents = parents.iter().collect::>(); + + let tree = try!( + repo.find_tree(tree_id) + .map_err_into(GHEK::RepositoryParentFetchingError) + .map_dbg_err_str("Failed to find tree") + .map_into_hook_error() + ); + + let message = try!(commit_message(&repo, cfg, action) + .map_dbg_err_str("Failed to get commit message")); + + try!(repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) + .map_dbg_str("Committed") + .map_dbg_err_str("Failed to commit") + .map_err_into(GHEK::RepositoryCommittingError) + .map_into_hook_error() + ); + + index.write() + .map_err_into(GHEK::RepositoryIndexWritingError) + .map_dbg_err_str("Failed to write tree") + .map_into_hook_error() + .map(|_| ()) } } From f9ea5c50137c1cffabb4ace99c3a74f7860d8b4a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 18:34:02 +0200 Subject: [PATCH 133/239] DeleteHook should be executed after the delete action --- libimagrt/src/runtime.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index a942b261..05eb3506 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -139,7 +139,7 @@ impl<'a> Runtime<'a> { let sp = storepath; let hooks : Vec<(Box, &str, HP)> = vec![ - (Box::new(GitDeleteHook::new(sp.clone(), HP::PreDelete)) , "vcs", HP::PreDelete), + (Box::new(GitDeleteHook::new(sp.clone(), HP::PostDelete)) , "vcs", HP::PostDelete), (Box::new(GitUpdateHook::new(sp, HP::PostUpdate)) , "vcs", HP::PostUpdate), ]; From c535e221b914c307803003a9f1bd4700eea00a42 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 9 Sep 2016 17:08:33 +0200 Subject: [PATCH 134/239] Do two matrix builds: one for binaries, one for libraries --- .travis.yml | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/.travis.yml b/.travis.yml index 77478906..5982e293 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,21 +20,20 @@ before_script: export PATH=$HOME/.local/bin:$PATH script: - | - libs_to_test="$(find . -maxdepth 1 name "libimag*" -printf "test-%f ")" - bins_to_build="$(find . -maxdepth 1 name "imag-*" -printf "%f ")" - make $libs_to_test && \ - make $bins_to_build && \ - for d in $(find -name "Cargo.toml" | grep -vE "^./Cargo.toml$"); do - dir=$(dirname $d) - { \ - echo "--- Running test scripts ---" && \ + if [[ "$TEST_SUITE" == "binaries" ]]; then + make $(find . -maxdepth 1 -name "imag-*" -type d -printf "%f ") && \ + for d in $(find -name "Cargo.toml" | grep -vE "^./Cargo.toml$"); do + dir=$(dirname $d) + echo "--- Running test scripts ---" for testsh in $(find $dir -iname "*test.sh"); do - echo "--- Running test script: '$1'" - bash $1 || { echo "--- Test failed. Exiting"; exit 1; } - echo "--- Test script $1 executed successfully" - done && \ - } || true - done + echo "--- Running test script: '$testsh'" + bash $testsh || { echo "--- Test failed. Exiting"; exit 1; } + echo "--- Test script $testsh executed successfully" + done + done + else # $TEST_SUITE == "libraries" + make $(find . -maxdepth 1 -name "libimag*" -printf "test-%f ") + fi addons: apt: @@ -58,6 +57,9 @@ notifications: template: - "%{repository_name} (%{branch} @ %{commit} by %{author}): %{result}" env: + matrix: + - TEST_SUITE=binaries + - TEST_SUITE=libraries global: - TRAVIS_CARGO_NIGHTLY_FEATURE=dev - secure: D+3exBnbvzFvk7fvLOxkF7UotCc4gBbvvOW4xGr9u6dDjEjV5y6CdDy/OQAkhfKhvSou+lIC22g5MuCBQXFEf/ua7A1XzwBAFeVLK4cWZSa7+ql6LdHKqOg3oF6pQlh095WeWr8S2PYJFFJFg8RGUPnbjqdu1J4KSXqe/7GoZ3lYS69mx7D5Hb93KEN084/KGfBuvyJtMjO1fK3spltL2zV8oqegFpv0gLG5GY4LsJ/7ij4Mc6wepXSyyQbaiA1eKMMwQZDvoi4V1mCulo/jeC3pucGxvgnMV5DZs8aa8R7votltGvSpHCgU78LW19dg8oZqwShQQ+XUYw27H+QK5V1lz1l1MaJLbwS3ySyZBPGH8qUuOzQ3bLp9xhAIRgCui3kX/UDhmeME7nJI6k3UZydh+/ydNB1BZHTKn76XS/yFj0Gcibxg7f5fcAYA6Ge5Sg+YPozuwbcKnKe6IpN2M7qNgWa+6MCSXJ1v4BgPb7kN74EynJUM8+yWEFN7MZtWEUQ4ZsHdCs8Pub4C/zHpYGV8qGenZwQzosAFq56YwoGCvJezz35yg4BDd3IMKenOzNnXLBrdxxqX8ySgwt5B3zBqwve/64Lx6OXjae2m8wZKlsmeqad/s6K7nx0zG15/qqRIzyvgcLXq3jwBaHkteq49FRFWvHQFpBQcsPZ2uH4= From eb378d47c2c37e04f5c4130aec023142212c6abe Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 18:57:46 +0200 Subject: [PATCH 135/239] Add helper fn to check whether the repository WD is dirty --- libimagstorestdhook/src/vcs/git/runtime.rs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 5a48d5be..3daf8bf8 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use git2::Repository; +use git2::{Index, Repository}; use toml::Value; use libimagerror::into::IntoError; @@ -154,5 +154,25 @@ impl Runtime { .map_dbg_str("[GIT CREATE HOOK]: Branch checked out") } + /// Check whether the WD is "dirty" - whether there is a diff to the repository + /// This function returns false if there is no `Repository` object in the `Runtime` + pub fn repo_is_dirty(&self, index: &Index) -> bool { + match self.repository.as_ref() { + Some(repo) => { + repo.diff_index_to_workdir(Some(index), None) + .map_dbg_str("Fetched diff: Index <-> WD") + .map_dbg_err_str("Failed to fetch diff: Index <-> WD") + .map(|diff| diff.deltas().count() != 0) + .unwrap_or(false) + }, + + None => { + debug!("No repository: Cannot fetch diff: Index <-> WD"); + false + } + } + + } + } From b2a0758b1ad24e0707c40ab375396acdd3a3a325 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 18:58:05 +0200 Subject: [PATCH 136/239] Abort the execution of the UpdateHook if repo isnt dirty --- libimagstorestdhook/src/vcs/git/update.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 70b37b49..d13dd987 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -106,6 +106,13 @@ impl StoreIdAccessor for UpdateHook { let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); + if !self.runtime.repo_is_dirty(&index) { + debug!("[GIT UPDATE HOOK]: Repository seems to be clean. I'm done."); + return Ok(()) + } else { + debug!("[GIT UPDATE HOOK]: Repository seems to be dirty. Continuing."); + } + let signature = try!( repo.signature() .map_err_into(GHEK::MkSignature) From 12e7544a2a25b4bf590c9081e2a1fb3ab634f264 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Sep 2016 19:25:37 +0200 Subject: [PATCH 137/239] Move code from libimagentryselect to libimaginteraction --- libimagentryselect/Cargo.toml | 16 ------------ libimagentryselect/README.md | 7 ----- libimagentryselect/src/error.rs | 13 ---------- libimagentryselect/src/lib.rs | 26 ------------------- libimagentryselect/src/result.rs | 6 ----- libimaginteraction/Cargo.toml | 9 ++++--- libimaginteraction/src/error.rs | 7 ++++- libimaginteraction/src/lib.rs | 2 ++ .../src/ui.rs | 14 +++++----- 9 files changed, 20 insertions(+), 80 deletions(-) delete mode 100644 libimagentryselect/Cargo.toml delete mode 100644 libimagentryselect/README.md delete mode 100644 libimagentryselect/src/error.rs delete mode 100644 libimagentryselect/src/lib.rs delete mode 100644 libimagentryselect/src/result.rs rename {libimagentryselect => libimaginteraction}/src/ui.rs (81%) diff --git a/libimagentryselect/Cargo.toml b/libimagentryselect/Cargo.toml deleted file mode 100644 index 19424a2c..00000000 --- a/libimagentryselect/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -[package] -name = "libimagentryselect" -version = "0.2.0" -authors = ["Matthias Beyer "] - -[dependencies] -clap = "2.*" -log = "0.3" -interactor = "0.1" - -[dependencies.libimagstore] -path = "../libimagstore" - -[dependencies.libimagerror] -path = "../libimagerror" - diff --git a/libimagentryselect/README.md b/libimagentryselect/README.md deleted file mode 100644 index de6c4825..00000000 --- a/libimagentryselect/README.md +++ /dev/null @@ -1,7 +0,0 @@ -# libimagentryselect - -Small library crate for asking the user to _select_ one or more entries out of -a list of entries. - -Not much functionality, yet. - diff --git a/libimagentryselect/src/error.rs b/libimagentryselect/src/error.rs deleted file mode 100644 index 767779e6..00000000 --- a/libimagentryselect/src/error.rs +++ /dev/null @@ -1,13 +0,0 @@ -generate_error_module!( - generate_error_types!(EntrySelectError, EntrySelectErrorKind, - CLIError => "Error on commandline", - IdMissingError => "Commandline: ID missing", - StoreIdParsingError => "Error while parsing StoreId", - IdSelectingError => "Error while selecting id" - ); -); - -pub use self::error::EntrySelectError; -pub use self::error::EntrySelectErrorKind; -pub use self::error::MapErrInto; - diff --git a/libimagentryselect/src/lib.rs b/libimagentryselect/src/lib.rs deleted file mode 100644 index 8f5bcbd3..00000000 --- a/libimagentryselect/src/lib.rs +++ /dev/null @@ -1,26 +0,0 @@ -#![deny( - non_camel_case_types, - non_snake_case, - path_statements, - trivial_numeric_casts, - unstable_features, - unused_allocation, - unused_import_braces, - unused_imports, - unused_mut, - unused_qualifications, - while_true, -)] - -extern crate clap; -extern crate log; -extern crate interactor; - -extern crate libimagstore; -#[macro_use] -extern crate libimagerror; - -pub mod error; -pub mod result; -pub mod ui; - diff --git a/libimagentryselect/src/result.rs b/libimagentryselect/src/result.rs deleted file mode 100644 index db949cf6..00000000 --- a/libimagentryselect/src/result.rs +++ /dev/null @@ -1,6 +0,0 @@ -use std::result::Result as RResult; - -use error::EntrySelectError; - -pub type Result = RResult; - diff --git a/libimaginteraction/Cargo.toml b/libimaginteraction/Cargo.toml index 7a78df33..d13b2823 100644 --- a/libimaginteraction/Cargo.toml +++ b/libimaginteraction/Cargo.toml @@ -4,12 +4,13 @@ version = "0.2.0" authors = ["Matthias Beyer "] [dependencies] -spinner = "0.4" -interactor = "0.1" -log = "0.3" ansi_term = "0.7.2" -regex = "0.1" +clap = "2.*" +interactor = "0.1" lazy_static = "0.1.15" +log = "0.3" +regex = "0.1" +spinner = "0.4" [dependencies.libimagstore] path = "../libimagstore" diff --git a/libimaginteraction/src/error.rs b/libimaginteraction/src/error.rs index 9285f0fd..ff347f1c 100644 --- a/libimaginteraction/src/error.rs +++ b/libimaginteraction/src/error.rs @@ -1,9 +1,14 @@ generate_error_module!( generate_error_types!(InteractionError, InteractionErrorKind, - Unknown => "Unknown Error" + Unknown => "Unknown Error", + CLIError => "Error on commandline", + IdMissingError => "Commandline: ID missing", + StoreIdParsingError => "Error while parsing StoreId", + IdSelectingError => "Error while selecting id" ); ); pub use self::error::InteractionError; pub use self::error::InteractionErrorKind; +pub use self::error::MapErrInto; diff --git a/libimaginteraction/src/lib.rs b/libimaginteraction/src/lib.rs index a608898f..b994ee21 100644 --- a/libimaginteraction/src/lib.rs +++ b/libimaginteraction/src/lib.rs @@ -18,6 +18,7 @@ extern crate interactor; extern crate ansi_term; #[macro_use] extern crate lazy_static; extern crate regex; +extern crate clap; extern crate libimagentryfilter; extern crate libimagstore; @@ -28,4 +29,5 @@ pub mod ask; pub mod error; pub mod filter; pub mod result; +pub mod ui; diff --git a/libimagentryselect/src/ui.rs b/libimaginteraction/src/ui.rs similarity index 81% rename from libimagentryselect/src/ui.rs rename to libimaginteraction/src/ui.rs index e3e41b8a..850a537e 100644 --- a/libimagentryselect/src/ui.rs +++ b/libimaginteraction/src/ui.rs @@ -7,7 +7,7 @@ use libimagerror::into::IntoError; use result::Result; use error::MapErrInto; -use error::EntrySelectErrorKind as ESEK; +use error::InteractionErrorKind as IEK; pub fn id_argument<'a, 'b>() -> Arg<'a, 'b> { Arg::with_name(id_argument_name()) @@ -33,14 +33,14 @@ pub fn id_argument_long() -> &'static str { pub fn get_id(matches: &ArgMatches) -> Result> { matches .values_of(id_argument_name()) - .ok_or(ESEK::IdMissingError.into_error()) - .map_err_into(ESEK::CLIError) + .ok_or(IEK::IdMissingError.into_error()) + .map_err_into(IEK::CLIError) .and_then(|vals| { vals.into_iter() .fold(Ok(vec![]), |acc, elem| { acc.and_then(|mut v| { let elem = StoreId::new_baseless(PathBuf::from(String::from(elem))); - let elem = try!(elem.map_err_into(ESEK::StoreIdParsingError)); + let elem = try!(elem.map_err_into(IEK::StoreIdParsingError)); v.push(elem); Ok(v) }) @@ -51,12 +51,12 @@ pub fn get_id(matches: &ArgMatches) -> Result> { pub fn get_or_select_id(matches: &ArgMatches, store_path: &PathBuf) -> Result> { use interactor::{pick_file, default_menu_cmd}; - match get_id(matches).map_err_into(ESEK::IdSelectingError) { + match get_id(matches).map_err_into(IEK::IdSelectingError) { Ok(v) => Ok(v), Err(_) => { let path = store_path.clone(); - let p = try!(pick_file(default_menu_cmd, path).map_err_into(ESEK::IdSelectingError)); - let id = try!(StoreId::new_baseless(p).map_err_into(ESEK::StoreIdParsingError)); + let p = try!(pick_file(default_menu_cmd, path).map_err_into(IEK::IdSelectingError)); + let id = try!(StoreId::new_baseless(p).map_err_into(IEK::StoreIdParsingError)); Ok(vec![id]) }, } From 23778d407c05bf04084be599a9b419a37c323f66 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 09:48:59 +0200 Subject: [PATCH 138/239] documentation: Remove dependency on libimagentryselect --- .imag-documentation/Cargo.toml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.imag-documentation/Cargo.toml b/.imag-documentation/Cargo.toml index 0d45f87b..5057179a 100644 --- a/.imag-documentation/Cargo.toml +++ b/.imag-documentation/Cargo.toml @@ -26,9 +26,6 @@ path = "../libimagentrylist" [dependencies.libimagentrymarkdown] path = "../libimagentrymarkdown" -[dependencies.libimagentryselect] -path = "../libimagentryselect" - [dependencies.libimagentrytag] path = "../libimagentrytag" From 40dbdaa5e194b760d2adcaae60b50bef1fa4cf89 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 14:44:08 +0200 Subject: [PATCH 139/239] Fix git hook registration fail warn message. --- libimagrt/src/runtime.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index 05eb3506..3e8ed7d8 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -147,7 +147,7 @@ impl<'a> Runtime<'a> { if let Err(e) = store.register_hook(position, &String::from(aspectname), hook) { if e.err_type() == StoreErrorKind::HookRegisterError { trace_error_dbg(&e); - warn!("Registering debug hook with store failed"); + warn!("Registering git hook with store failed"); } else { trace_error(&e); }; From 9a4cdad9a1d042881f189d9306e115939cb738a5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 14:50:41 +0200 Subject: [PATCH 140/239] Add StoreAction::as_commit_message() utility fn --- libimagstorestdhook/src/vcs/git/action.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/action.rs b/libimagstorestdhook/src/vcs/git/action.rs index fbfa3fe4..d179dbda 100644 --- a/libimagstorestdhook/src/vcs/git/action.rs +++ b/libimagstorestdhook/src/vcs/git/action.rs @@ -19,6 +19,15 @@ impl StoreAction { StoreAction::Delete => "DELETE", } } + + pub fn as_commit_message(&self) -> &str { + match *self { + StoreAction::Create => "Create", + StoreAction::Retrieve => "Retrieve", + StoreAction::Update => "Update", + StoreAction::Delete => "Delete", + } + } } impl Display for StoreAction { From cb3a536adb9e987710b40a7a519f7025af9ffe23 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 14:50:55 +0200 Subject: [PATCH 141/239] Fix warn!() output to be action sensitive --- libimagstorestdhook/src/vcs/git/config.rs | 35 ++++++++++++----------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index a75d99b1..49d4a3c1 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -11,17 +11,18 @@ use vcs::git::action::StoreAction; use git2::Repository; /// Check the configuration whether we should commit interactively -pub fn commit_interactive(config: &Value) -> bool { +pub fn commit_interactive(config: &Value, action: &StoreAction) -> bool { match config.lookup("commit.interactive") { Some(&Value::Boolean(b)) => b, Some(_) => { - warn!("Configuration error, 'store.hooks.stdhook_git_update.commit.interactive' must be a Boolean."); + warn!("Configuration error, 'store.hooks.stdhook_git_{}.commit.interactive' must be a Boolean.", + action); warn!("Defaulting to commit.interactive = false"); false } None => { warn!("Unavailable configuration for"); - warn!("\t'store.hooks.stdhook_git_update.commit.interactive'"); + warn!("\t'store.hooks.stdhook_git_{}.commit.interactive'", action); warn!("Defaulting to false"); false } @@ -29,17 +30,18 @@ pub fn commit_interactive(config: &Value) -> bool { } /// Check the configuration whether we should commit with the editor -fn commit_with_editor(config: &Value) -> bool { +fn commit_with_editor(config: &Value, action: &StoreAction) -> bool { match config.lookup("commit.interactive_editor") { Some(&Value::Boolean(b)) => b, Some(_) => { - warn!("Configuration error, 'store.hooks.stdhook_git_update.commit.interactive_editor' must be a Boolean."); + warn!("Configuration error, 'store.hooks.stdhook_git_{}.commit.interactive_editor' must be a Boolean.", + action); warn!("Defaulting to commit.interactive_editor = false"); false } None => { warn!("Unavailable configuration for"); - warn!("\t'store.hooks.stdhook_git_update.commit.interactive_editor'"); + warn!("\t'store.hooks.stdhook_git_{}.commit.interactive_editor'", action); warn!("Defaulting to false"); false } @@ -47,19 +49,20 @@ fn commit_with_editor(config: &Value) -> bool { } /// Get the commit default message -fn commit_default_msg<'a>(config: &'a Value) -> &'a str { +fn commit_default_msg<'a>(config: &'a Value, action: &'a StoreAction) -> &'a str { match config.lookup("commit.message") { Some(&Value::String(ref b)) => b, Some(_) => { - warn!("Configuration error, 'store.hooks.stdhook_git_update.commit.message' must be a String."); - warn!("Defaulting to commit.message = 'Update'"); - "Update" + warn!("Configuration error, 'store.hooks.stdhook_git_{}.commit.message' must be a String.", + action); + warn!("Defaulting to commit.message = '{}'", action.as_commit_message()); + action.as_commit_message() } None => { warn!("Unavailable configuration for"); - warn!("\t'store.hooks.stdhook_git_update.commit.message'"); - warn!("Defaulting to commit.message = 'Update'"); - "Update" + warn!("\t'store.hooks.stdhook_git_{}.commit.message'", action); + warn!("Defaulting to commit.message = '{}'", action.as_commit_message()); + action.as_commit_message() } } } @@ -81,8 +84,8 @@ pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction) -> use libimagutil::edit::edit_in_tmpfile_with_command; use std::process::Command; - if commit_interactive(config) { - if commit_with_editor(config) { + if commit_interactive(config, &action) { + if commit_with_editor(config, &action) { repo.config() .map_err_into(GHEK::GitConfigFetchError) .and_then(|c| c.get_string("core.editor").map_err_into(GHEK::GitConfigEditorFetchError)) @@ -97,7 +100,7 @@ pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction) -> Ok(ask_string("Commit Message", None, false, false, None, "> ")) } } else { - Ok(String::from(commit_default_msg(config))) + Ok(String::from(commit_default_msg(config, &action))) } } From b288e938f9cc256acdd76aaab78fe04b08451c93 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 14:52:00 +0200 Subject: [PATCH 142/239] Minify error handling in Store::update() --- libimagstore/src/store.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index 5922b35f..bdda753e 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -493,10 +493,7 @@ impl Store { /// Return the `FileLockEntry` and write to disk pub fn update<'a>(&'a self, mut entry: FileLockEntry<'a>) -> Result<()> { - if let Err(e) = self._update(&mut entry) { - return Err(e).map_err_into(SEK::UpdateCallError); - } - Ok(()) + self._update(&mut entry).map_err_into(SEK::UpdateCallError) } /// Internal method to write to the filesystem store. From 07ff755ed79fe8193fde52390406ec00c0577526 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 14:52:55 +0200 Subject: [PATCH 143/239] Minify error handling in Store::_update with try!() --- libimagstore/src/store.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index bdda753e..f2d0af99 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -502,12 +502,11 @@ impl Store { /// This method assumes that entry is dropped _right after_ the call, hence /// it is not public. fn _update<'a>(&'a self, entry: &mut FileLockEntry<'a>) -> Result<()> { - if let Err(e) = self.execute_hooks_for_mut_file(self.pre_update_aspects.clone(), entry) { - return Err(e) - .map_err_into(SEK::PreHookExecuteError) - .map_err_into(SEK::HookExecutionError) - .map_err_into(SEK::UpdateCallError); - } + let _ = try!(self.execute_hooks_for_mut_file(self.pre_update_aspects.clone(), entry) + .map_err_into(SEK::PreHookExecuteError) + .map_err_into(SEK::HookExecutionError) + .map_err_into(SEK::UpdateCallError) + ); let mut hsmap = match self.entries.write() { Err(_) => return Err(SE::new(SEK::LockPoisoned, None)), From 15dcb26fd226736988e2f959dae71ab7530529c7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 14:54:38 +0200 Subject: [PATCH 144/239] Minify Runtime::new() by refactoring error tracing --- libimagstorestdhook/src/vcs/git/runtime.rs | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 3daf8bf8..b35a453f 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -4,7 +4,7 @@ use git2::{Index, Repository}; use toml::Value; use libimagerror::into::IntoError; -use libimagerror::trace::trace_error; +use libimagerror::trace::{MapErrTrace, trace_error}; use libimagstore::hook::error::CustomData; use libimagstore::hook::error::HookErrorKind as HEK; use libimagstore::hook::result::HookResult; @@ -31,14 +31,7 @@ impl Runtime { /// returns a `Runtime` object that does _not_ contain a `Repository`. pub fn new(storepath: &PathBuf) -> Runtime { Runtime { - repository: match Repository::open(storepath) { - Ok(r) => Some(r), - Err(e) => { - trace_error(&e); - None - }, - }, - + repository: Repository::open(storepath).map_err_trace().ok(), config: None, } } From c5f95e3538febef4118da79625dcbd5e47145510 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 15:00:36 +0200 Subject: [PATCH 145/239] Add debug output for UpdateHook --- libimagstorestdhook/src/vcs/git/update.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index d13dd987..a85a61a1 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -117,6 +117,7 @@ impl StoreIdAccessor for UpdateHook { repo.signature() .map_err_into(GHEK::MkSignature) .map_dbg_err_str("Failed to fetch signature") + .map_dbg_str("[GIT UPDATE HOOK]: Fetched signature object") .map_into_hook_error() ); @@ -124,6 +125,7 @@ impl StoreIdAccessor for UpdateHook { repo.head() .map_err_into(GHEK::HeadFetchError) .map_dbg_err_str("Failed to fetch HEAD") + .map_dbg_str("[GIT UPDATE HOOK]: Fetched HEAD") .map_into_hook_error() ); @@ -132,6 +134,7 @@ impl StoreIdAccessor for UpdateHook { .status_file(id.local()) .map_dbg_err_str("Failed to fetch file status") .map_dbg_err(|e| format!("\t-> {:?}", e)) + .map_dbg_str("[GIT UPDATE HOOK]: Fetched file status") .map_err_into(GHEK::RepositoryFileStatusError) .map_into_hook_error() ); @@ -150,6 +153,7 @@ impl StoreIdAccessor for UpdateHook { index.add_all(&[id.local()], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) .map_err_into(GHEK::RepositoryPathAddingError) .map_dbg_err_str("Failed to add to index") + .map_dbg(|_| format!("[GIT UPDATE HOOK]: Added id ({:?}) to index", id)) .map_into_hook_error() ); @@ -157,6 +161,7 @@ impl StoreIdAccessor for UpdateHook { index.write_tree() .map_err_into(GHEK::RepositoryIndexWritingError) .map_dbg_err_str("Failed to write tree") + .map_dbg_str("[GIT UPDATE HOOK]: Wrote tree") .map_into_hook_error() ); @@ -166,6 +171,7 @@ impl StoreIdAccessor for UpdateHook { repo.find_commit(head.target().unwrap()) .map_err_into(GHEK::RepositoryParentFetchingError) .map_dbg_err_str("Failed to find commit HEAD") + .map_dbg_str("[GIT UPDATE HOOK]: Fetched commit parents of HEAD") .map_into_hook_error() ); parents.push(commit); @@ -178,11 +184,13 @@ impl StoreIdAccessor for UpdateHook { repo.find_tree(tree_id) .map_err_into(GHEK::RepositoryParentFetchingError) .map_dbg_err_str("Failed to find tree") + .map_dbg_str("[GIT UPDATE HOOK]: Found Tree for parents") .map_into_hook_error() ); let message = try!(commit_message(&repo, cfg, StoreAction::Update) - .map_dbg_err_str("Failed to get commit message")); + .map_dbg_err_str("Failed to get commit message") + .map_dbg_str("[GIT UPDATE HOOK]: Fetched commit message")); try!(repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) .map_dbg_str("Committed") From bdbf136fef36622a52ae2796c2a63611b9c8c9fb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 15:03:07 +0200 Subject: [PATCH 146/239] Add debug output for DeleteHook --- libimagstorestdhook/src/vcs/git/delete.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index 63e9f65c..8b1c791b 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -96,6 +96,7 @@ impl StoreIdAccessor for DeleteHook { repo.signature() .map_err_into(GHEK::MkSignature) .map_dbg_err_str("Failed to fetch signature") + .map_dbg_str("[GIT DELETE HOOK]: Fetched signature object") .map_into_hook_error() ); @@ -103,6 +104,7 @@ impl StoreIdAccessor for DeleteHook { repo.head() .map_err_into(GHEK::HeadFetchError) .map_dbg_err_str("Failed to fetch HEAD") + .map_dbg_str("[GIT DELETE HOOK]: Fetched HEAD") .map_into_hook_error() ); @@ -111,6 +113,7 @@ impl StoreIdAccessor for DeleteHook { .status_file(id.local()) .map_dbg_err_str("Failed to fetch file status") .map_dbg_err(|e| format!("\t-> {:?}", e)) + .map_dbg_str("[GIT DELETE HOOK]: Fetched file status") .map_err_into(GHEK::RepositoryFileStatusError) .map_into_hook_error() ); @@ -130,6 +133,7 @@ impl StoreIdAccessor for DeleteHook { index.add_all(&[id.local()], ADD_DEFAULT, Some(cb as &mut IndexMatchedPath)) .map_err_into(GHEK::RepositoryPathAddingError) .map_dbg_err_str("Failed to add to index") + .map_dbg_str("[GIT DELETE HOOK]: Fetched index") .map_into_hook_error() ); @@ -137,6 +141,7 @@ impl StoreIdAccessor for DeleteHook { index.write_tree() .map_err_into(GHEK::RepositoryIndexWritingError) .map_dbg_err_str("Failed to write tree") + .map_dbg_str("[GIT DELETE HOOK]: Wrote index tree") .map_into_hook_error() ); @@ -146,6 +151,7 @@ impl StoreIdAccessor for DeleteHook { repo.find_commit(head.target().unwrap()) .map_err_into(GHEK::RepositoryParentFetchingError) .map_dbg_err_str("Failed to find commit HEAD") + .map_dbg_str("[GIT DELETE HOOK]: Found commit HEAD") .map_into_hook_error() ); parents.push(commit); @@ -158,15 +164,18 @@ impl StoreIdAccessor for DeleteHook { repo.find_tree(tree_id) .map_err_into(GHEK::RepositoryParentFetchingError) .map_dbg_err_str("Failed to find tree") + .map_dbg_str("[GIT DELETE HOOK]: Found tree for index") .map_into_hook_error() ); let message = try!(commit_message(&repo, cfg, action) - .map_dbg_err_str("Failed to get commit message")); + .map_dbg_err_str("Failed to get commit message") + .map_dbg_str("[GIT DELETE HOOK]: Got commit message")); try!(repo.commit(Some("HEAD"), &signature, &signature, &message, &tree, &parents) .map_dbg_str("Committed") .map_dbg_err_str("Failed to commit") + .map_dbg_str("[GIT DELETE HOOK]: Committed") .map_err_into(GHEK::RepositoryCommittingError) .map_into_hook_error() ); @@ -174,6 +183,7 @@ impl StoreIdAccessor for DeleteHook { index.write() .map_err_into(GHEK::RepositoryIndexWritingError) .map_dbg_err_str("Failed to write tree") + .map_dbg_str("[GIT DELETE HOOK]: Wrote index") .map_into_hook_error() .map(|_| ()) } From 556c464bbfa7879619eb8b083ee31e2da16ebdc6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 15:07:37 +0200 Subject: [PATCH 147/239] Remove unused error kinds --- libimagstorestdhook/src/vcs/git/error.rs | 26 ++++++++---------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index d63c792e..c15640d5 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -9,35 +9,27 @@ generate_error_module!( ConfigError => "Configuration Error", NoConfigError => "No Configuration", ConfigTypeError => "Configuration value type wrong", - RuntimeInformationSetupError => "Couldn't setup runtime information for git hook", - RepositoryBackendError => "Error in the git library", + RepositoryError => "Error while interacting with git repository", + RepositoryBackendError => "Error in the git library", RepositoryBranchError => "Error while interacting with git branch(es)", RepositoryBranchNameFetchingError => "Error while fetching branch name", - RepositorySignatureFetchingError => "Error while fetching Authors/Committers signature", RepositoryIndexFetchingError => "Error while fetching Repository Index", RepositoryIndexWritingError => "Error while writing Repository Index", RepositoryPathAddingError => "Error while adding Path to Index", - RepositoryTreeWritingError => "Error while writing repository tree", - RepositoryTreeFindingError => "Error while finding repository tree", - RepositoryCommitFindingError => "Error while finding commit", RepositoryCommittingError => "Error while committing", - RepositoryHeadFetchingError => "Error while fetching HEAD", - RepositoryHeadTargetFetchingError => "Error while fetching target of HEAD", RepositoryParentFetchingError => "Error while fetching parent of commit", + HeadFetchError => "Error while getting HEAD", NotOnBranch => "No Branch is checked out", - MkRepo => "Repository creation error", - MkSignature => "Error while building Signature object", - StoreIdHandlingError => "Error handling the store id object", - StoreIdStripError => "Couldn't strip prefix from StoreID object", + MkRepo => "Repository creation error", + MkSignature => "Error while building Signature object", - RepositoryFileStatusError => "Error while getting file status", + RepositoryFileStatusError => "Error while getting file status", - GitConfigFetchError => "Error fetching git config", - GitConfigEditorFetchError => "Error fetching 'editor' from git config", - CommitEditorInstantiationError => "Error when trying to instantiate commit editor", - EditorError => "Error while calling editor" + GitConfigFetchError => "Error fetching git config", + GitConfigEditorFetchError => "Error fetching 'editor' from git config", + EditorError => "Error while calling editor" ); ); From 68e1f4f61ce579fa1e496a5d789afbcae171a203 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 15:19:47 +0200 Subject: [PATCH 148/239] Provide better commit template message, including action and store id --- libimagstorestdhook/src/vcs/git/config.rs | 18 ++++++++++++++---- libimagstorestdhook/src/vcs/git/delete.rs | 2 +- libimagstorestdhook/src/vcs/git/update.rs | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 49d4a3c1..c18b8cb1 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -1,6 +1,7 @@ use toml::Value; use libimagerror::into::IntoError; +use libimagstore::storeid::StoreId; use vcs::git::error::GitHookErrorKind as GHEK; use vcs::git::error::MapErrInto; @@ -70,8 +71,17 @@ fn commit_default_msg<'a>(config: &'a Value, action: &'a StoreAction) -> &'a str /// Get the commit template /// /// TODO: Implement good template string -fn commit_template() -> &'static str { - "Commit template" +fn commit_template(action: &StoreAction, id: &StoreId) -> String { + format!(r#" +# Please commit your changes and remove these lines. +# +# You're about to commit changes via the {action} Hook +# +# Altered file: {id} +# + "#, + action = action, + id = id.local().display()) } /// Generate a commit message @@ -79,7 +89,7 @@ fn commit_template() -> &'static str { /// Uses the functions `commit_interactive()` and `commit_with_editor()` /// or reads one from the commandline or uses the `commit_default_msg()` string to create a commit /// message. -pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction) -> Result { +pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction, id: &StoreId) -> Result { use libimaginteraction::ask::ask_string; use libimagutil::edit::edit_in_tmpfile_with_command; use std::process::Command; @@ -92,7 +102,7 @@ pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction) -> .map_err_into(GHEK::ConfigError) .map(Command::new) .and_then(|cmd| { - let mut s = String::from(commit_template()); + let mut s = commit_template(&action, id); edit_in_tmpfile_with_command(cmd, &mut s).map(|_| s) .map_err_into(GHEK::EditorError) }) diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index 8b1c791b..51528067 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -168,7 +168,7 @@ impl StoreIdAccessor for DeleteHook { .map_into_hook_error() ); - let message = try!(commit_message(&repo, cfg, action) + let message = try!(commit_message(&repo, cfg, action, &id) .map_dbg_err_str("Failed to get commit message") .map_dbg_str("[GIT DELETE HOOK]: Got commit message")); diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index a85a61a1..9576d6ec 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -188,7 +188,7 @@ impl StoreIdAccessor for UpdateHook { .map_into_hook_error() ); - let message = try!(commit_message(&repo, cfg, StoreAction::Update) + let message = try!(commit_message(&repo, cfg, StoreAction::Update, &id) .map_dbg_err_str("Failed to get commit message") .map_dbg_str("[GIT UPDATE HOOK]: Fetched commit message")); From 27eaf4cf6ef989d1bc324a387cc40e49b1479daf Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:17:38 +0200 Subject: [PATCH 149/239] Revert "Disable lints" This reverts commit 010109a3c3103ae888a2db388c1a998ea4bea1fd. --- libimagstorestdhook/src/lib.rs | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/libimagstorestdhook/src/lib.rs b/libimagstorestdhook/src/lib.rs index 76b15b7e..bca7eb2c 100644 --- a/libimagstorestdhook/src/lib.rs +++ b/libimagstorestdhook/src/lib.rs @@ -1,18 +1,18 @@ -// #![deny( -// dead_code, -// non_camel_case_types, -// non_snake_case, -// path_statements, -// trivial_numeric_casts, -// unstable_features, -// unused_allocation, -// unused_import_braces, -// unused_imports, -// unused_must_use, -// unused_mut, -// unused_qualifications, -// while_true, -// )] +#![deny( + dead_code, + non_camel_case_types, + non_snake_case, + path_statements, + trivial_numeric_casts, + unstable_features, + unused_allocation, + unused_import_braces, + unused_imports, + unused_must_use, + unused_mut, + unused_qualifications, + while_true, +)] #[macro_use] extern crate log; extern crate toml; From 573745b9f3a7095a4217cb5fbddfbf09e89a8313 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:28:39 +0200 Subject: [PATCH 150/239] Add error kind for repo initialization errors --- libimagstorestdhook/src/vcs/git/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index c15640d5..e4bdb3ae 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -11,6 +11,7 @@ generate_error_module!( ConfigTypeError => "Configuration value type wrong", RepositoryError => "Error while interacting with git repository", + RepositoryInitError => "Error while loading the git repository", RepositoryBackendError => "Error in the git library", RepositoryBranchError => "Error while interacting with git branch(es)", RepositoryBranchNameFetchingError => "Error while fetching branch name", From a321ad941c31a2e47fcc0bd42ae4aa27dd8aa943 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:28:45 +0200 Subject: [PATCH 151/239] DeleteHook: Add config-based abort if repo init failed --- libimagstorestdhook/src/vcs/git/delete.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index 51528067..6f89cba8 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -79,15 +79,34 @@ impl HookDataAccessorProvider for DeleteHook { impl StoreIdAccessor for DeleteHook { fn access(&self, id: &StoreId) -> HookResult<()> { + use libimagerror::into::IntoError; use vcs::git::action::StoreAction; use vcs::git::config::commit_message; use vcs::git::error::MapIntoHookError; use vcs::git::util::fetch_index; + use vcs::git::config::abort_on_repo_init_err; use git2::{ADD_DEFAULT, STATUS_WT_DELETED, IndexMatchedPath}; debug!("[GIT DELETE HOOK]: {:?}", id); - let action = StoreAction::Delete; + let action = StoreAction::Delete; + + if !self.runtime.has_repository() { + debug!("[GIT DELETE HOOK]: Runtime has no repository..."); + if try!(self.runtime.config_value_or_err(&action).map(|c| abort_on_repo_init_err(c))) { + // Abort on repo init failure + debug!("[GIT DELETE HOOK]: Config says we should abort if we have no repository"); + debug!("[GIT DELETE HOOK]: Returing Err(_)"); + return Err(GHEK::RepositoryInitError.into_error()) + .map_err_into(GHEK::RepositoryError) + .map_into_hook_error() + } else { + debug!("[GIT DELETE HOOK]: Config says it is okay to not have a repository"); + debug!("[GIT DELETE HOOK]: Returing Ok(())"); + return Ok(()) + } + } + let cfg = try!(self.runtime.config_value_or_err(&action)); let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); From 81cc6c822b180de8fb0996545feeb8b6f3f8bec6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:29:31 +0200 Subject: [PATCH 152/239] UpdateHook: Add config-based abort if repo init failed --- libimagstorestdhook/src/vcs/git/update.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 9576d6ec..8b0186ec 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -93,15 +93,34 @@ impl StoreIdAccessor for UpdateHook { /// if there is no configuration for an interactive commit. /// fn access(&self, id: &StoreId) -> HookResult<()> { + use libimagerror::into::IntoError; use vcs::git::action::StoreAction; use vcs::git::config::commit_message; use vcs::git::error::MapIntoHookError; use vcs::git::util::fetch_index; + use vcs::git::config::abort_on_repo_init_err; use git2::{ADD_DEFAULT, STATUS_WT_NEW, STATUS_WT_MODIFIED, IndexMatchedPath}; debug!("[GIT UPDATE HOOK]: {:?}", id); - let action = StoreAction::Update; + let action = StoreAction::Update; + + if !self.runtime.has_repository() { + debug!("[GIT UPDATE HOOK]: Runtime has no repository..."); + if try!(self.runtime.config_value_or_err(&action).map(|c| abort_on_repo_init_err(c))) { + // Abort on repo init failure + debug!("[GIT UPDATE HOOK]: Config says we should abort if we have no repository"); + debug!("[GIT UPDATE HOOK]: Returing Err(_)"); + return Err(GHEK::RepositoryInitError.into_error()) + .map_err_into(GHEK::RepositoryError) + .map_into_hook_error() + } else { + debug!("[GIT UPDATE HOOK]: Config says it is okay to not have a repository"); + debug!("[GIT UPDATE HOOK]: Returing Ok(())"); + return Ok(()) + } + } + let cfg = try!(self.runtime.config_value_or_err(&action)); let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); From 0f1c36098132b905c38d972839e9263e24c152fe Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:31:10 +0200 Subject: [PATCH 153/239] DeleteHook: Ensure the right branch is checked out --- libimagstorestdhook/src/vcs/git/delete.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index 6f89cba8..b44bf878 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -107,6 +107,7 @@ impl StoreIdAccessor for DeleteHook { } } + let _ = try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); let cfg = try!(self.runtime.config_value_or_err(&action)); let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); From a4cdb2b8731c1eea031af397aecd3fe657d6c889 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:31:23 +0200 Subject: [PATCH 154/239] UpdateHook: Ensure the right branch is checked out --- libimagstorestdhook/src/vcs/git/update.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 8b0186ec..25ada8a6 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -121,6 +121,7 @@ impl StoreIdAccessor for UpdateHook { } } + let _ = try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); let cfg = try!(self.runtime.config_value_or_err(&action)); let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); From 4a0def0ede9c94609999f6e93cad5c9e25373c48 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:34:01 +0200 Subject: [PATCH 155/239] Fix debug messages in Runtime::ensure_cfg_branch_is_checked_out() --- libimagstorestdhook/src/vcs/git/runtime.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index b35a453f..a306c83c 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -92,40 +92,40 @@ impl Runtime { pub fn ensure_cfg_branch_is_checked_out(&self, action: &StoreAction) -> HookResult<()> { use vcs::git::config::ensure_branch; - debug!("[GIT CREATE HOOK]: Ensuring branch checkout"); + debug!("[GIT {} HOOK]: Ensuring branch checkout", action.uppercase()); let head = try!(self .repository(action) .and_then(|r| { - debug!("Repository fetched, getting head"); + debug!("[GIT {} HOOK]: Repository fetched, getting head", action.uppercase()); r.head() .map_dbg_err_str("Couldn't fetch HEAD") .map_dbg_err(|e| format!("\tbecause = {:?}", e)) .map_err_into(GHEK::HeadFetchError) .map_err(|e| e.into()) })); - debug!("HEAD fetched"); + debug!("[GIT {} HOOK]: HEAD fetched", action.uppercase()); // TODO: Fail if not on branch? hmmh... I'm not sure if !head.is_branch() { - debug!("HEAD is not a branch"); + debug!("[GIT {} HOOK]: HEAD is not a branch", action.uppercase()); return Err(GHEK::NotOnBranch.into_error().into()); } - debug!("HEAD is a branch"); + debug!("[GIT {} HOOK]: HEAD is a branch", action.uppercase()); // Check out appropriate branch ... or fail match ensure_branch(self.config.as_ref()) { Ok(Some(s)) => { - debug!("We have to ensure branch: {}", s); + debug!("[GIT {} HOOK]: We have to ensure branch: {}", action.uppercase(), s); match head.name().map(|name| { - debug!("{} == {}", name, s); + debug!("[GIT {} HOOK]: {} == {}", action.uppercase(), name, s); name == s }) { Some(b) => { if b { - debug!("Branch already checked out."); + debug!("[GIT {} HOOK]: Branch already checked out.", action.uppercase()); Ok(()) } else { - debug!("Branch not checked out."); + debug!("[GIT {} HOOK]: Branch not checked out.", action.uppercase()); unimplemented!() } }, @@ -136,7 +136,7 @@ impl Runtime { } }, Ok(None) => { - debug!("No branch to checkout"); + debug!("[GIT {} HOOK]: No branch to checkout", action.uppercase()); Ok(()) }, From 73c0f080ac445617b0ba65db2cbe69fcbc872327 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:47:40 +0200 Subject: [PATCH 156/239] Change abort_on_repo_init_err() to take Value instead of Option --- libimagstorestdhook/src/vcs/git/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index c18b8cb1..db1a4d3d 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -115,8 +115,8 @@ pub fn commit_message(repo: &Repository, config: &Value, action: StoreAction, id } /// Check whether the hook should abort if the repository cannot be initialized -pub fn abort_on_repo_init_err(cfg: Option<&Value>) -> bool { - get_bool_cfg(cfg, "abort_on_repo_init_failure", true, true) +pub fn abort_on_repo_init_err(cfg: &Value) -> bool { + get_bool_cfg(Some(cfg), "abort_on_repo_init_failure", true, true) } /// Get the branch which must be checked out before running the hook (if any). From cae605d21b38c47f4e37730d33a1138050737737 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:51:15 +0200 Subject: [PATCH 157/239] Runtime::ensure_cfg_branch_is_checked_out() should check whether config enforces this --- libimagstorestdhook/src/vcs/git/runtime.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index a306c83c..45ffa29a 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -91,6 +91,11 @@ impl Runtime { /// Ensure that the branch that is put in the configuration file is checked out, if any. pub fn ensure_cfg_branch_is_checked_out(&self, action: &StoreAction) -> HookResult<()> { use vcs::git::config::ensure_branch; + use vcs::git::config::do_checkout_ensure_branch; + + if !do_checkout_ensure_branch(self.config.as_ref()) { + return Ok(()) + } debug!("[GIT {} HOOK]: Ensuring branch checkout", action.uppercase()); let head = try!(self From cf77c51afb59a4276bf1d55784dfa0e88b77e0ca Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:51:50 +0200 Subject: [PATCH 158/239] Variable hasnt to be mutable --- libimagstorestdhook/src/vcs/git/runtime.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 45ffa29a..51ac4714 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -64,7 +64,7 @@ impl Runtime { .map_err_into(GHEK::ConfigError) .map_err(Box::new) .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)) - .map_err(|mut e| e.with_custom_data(CustomData::default().aborting(false))) + .map_err(|e| e.with_custom_data(CustomData::default().aborting(false))) .map_dbg_err(|_| { format!("[GIT {} HOOK]: Couldn't get Value object from config", action.uppercase()) }) From 76f92da898d6826da6d51af4fad2502e8957f937 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Sep 2016 18:52:36 +0200 Subject: [PATCH 159/239] Remove unused import --- libimagstorestdhook/src/vcs/git/runtime.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 51ac4714..05878b39 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -4,7 +4,7 @@ use git2::{Index, Repository}; use toml::Value; use libimagerror::into::IntoError; -use libimagerror::trace::{MapErrTrace, trace_error}; +use libimagerror::trace::MapErrTrace; use libimagstore::hook::error::CustomData; use libimagstore::hook::error::HookErrorKind as HEK; use libimagstore::hook::result::HookResult; From 352f468a27fa60df5734b29f803fa63802658dd7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 19 Sep 2016 09:47:37 +0200 Subject: [PATCH 160/239] Fix: We have to specify the full ref name in the cfg --- imagrc.toml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/imagrc.toml b/imagrc.toml index 83f7e480..de8d39ba 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -61,7 +61,7 @@ aspect = "vcs" abort_on_repo_init_failure = true # Ensure to be on this branche before doing anything. -ensure_branch = "master" +ensure_branch = "refs/heads/master" # Try to checkout the ensure_branch if it isn't checked out try_checkout_ensure_branch = true @@ -75,7 +75,7 @@ aspect = "vcs" abort_on_repo_init_failure = true # Ensure to be on this branche before doing anything. -ensure_branch = "master" +ensure_branch = "refs/heads/master" # Try to checkout the ensure_branch if it isn't checked out try_checkout_ensure_branch = true @@ -103,7 +103,7 @@ aspect = "vcs" abort_on_repo_init_failure = true # Ensure to be on this branche before doing anything. -ensure_branch = "master" +ensure_branch = "refs/heads/master" # Try to checkout the ensure_branch if it isn't checked out try_checkout_ensure_branch = true From a74b46deeda3b115b7e6a1924704e94e6657e356 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 19 Sep 2016 09:52:21 +0200 Subject: [PATCH 161/239] Add error kind for wrong branch checked out --- libimagstorestdhook/src/vcs/git/error.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index e4bdb3ae..9f006a03 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -15,6 +15,7 @@ generate_error_module!( RepositoryBackendError => "Error in the git library", RepositoryBranchError => "Error while interacting with git branch(es)", RepositoryBranchNameFetchingError => "Error while fetching branch name", + RepositoryWrongBranchError => "Error because repository is on wrong branch", RepositoryIndexFetchingError => "Error while fetching Repository Index", RepositoryIndexWritingError => "Error while writing Repository Index", RepositoryPathAddingError => "Error while adding Path to Index", From 43bdedea8e601ad771e737fbb712a7e27a9e86f5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 19 Sep 2016 09:52:37 +0200 Subject: [PATCH 162/239] Fix check whether we should checkout the ensure_branch We should test this not at the top of the function, as if we do not have to check out the ensure_branch, we still have to verify that there actually is a branch checked out we have to ensure. What I'm saying is: We might have to be on "master", but we might not have to check it out if we aren't. Therefor, this commit moves the location where we check whether we should checkout the branch. --- libimagstorestdhook/src/vcs/git/runtime.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 05878b39..4e37002d 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -93,10 +93,6 @@ impl Runtime { use vcs::git::config::ensure_branch; use vcs::git::config::do_checkout_ensure_branch; - if !do_checkout_ensure_branch(self.config.as_ref()) { - return Ok(()) - } - debug!("[GIT {} HOOK]: Ensuring branch checkout", action.uppercase()); let head = try!(self .repository(action) @@ -131,7 +127,14 @@ impl Runtime { Ok(()) } else { debug!("[GIT {} HOOK]: Branch not checked out.", action.uppercase()); - unimplemented!() + + if !do_checkout_ensure_branch(self.config.as_ref()) { + Err(GHEK::RepositoryWrongBranchError.into_error()) + .map_err_into(GHEK::RepositoryError) + } else { + // Else try to check out the branch... + unimplemented!() + } } }, From f5d73ace0e8bc0bed5c188146379fd97943ad009 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 19 Sep 2016 10:00:35 +0200 Subject: [PATCH 163/239] Fix debug output, use action to generate msg --- libimagstorestdhook/src/vcs/git/runtime.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 4e37002d..0fb26326 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -152,7 +152,7 @@ impl Runtime { } .map_err(Box::new) .map_err(|e| HEK::HookExecutionError.into_error_with_cause(e)) - .map_dbg_str("[GIT CREATE HOOK]: Branch checked out") + .map_dbg(|_| format!("[GIT {} HOOK]: Branch checked out", action.uppercase())) } /// Check whether the WD is "dirty" - whether there is a diff to the repository From 12b6da5c905796d49acd35b33b8174b8aec6448c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 10 Sep 2016 09:42:57 +0200 Subject: [PATCH 164/239] Add first idea how to exec all the tests in the Makefile --- Makefile | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Makefile b/Makefile index 1199a133..fcbf7cd8 100644 --- a/Makefile +++ b/Makefile @@ -4,12 +4,14 @@ bin = $@/target/debug/$@ doc-crate-toml=./.imag-documentation/Cargo.toml ECHO=$(shell which echo) -e +BASH=$(shell which bash) CARGO=$(shell which cargo) BINS=$(shell find -maxdepth 1 -name "imag-*" -type d) LIBS=$(shell find -maxdepth 1 -name "libimag*" -type d) BIN_TARGETS=$(patsubst imag-%,,$(BINS)) +BIN_TARGET_TESTS=$(foreach x,$(BIN_TARGETS),$(x)-test) LIB_TARGETS=$(LIBS) LIB_TARGETS_TEST=$(foreach x,$(subst ./,,$(LIBS)),test-$(x)) TARGETS=$(BIN_TARGETS) $(LIB_TARGETS) @@ -65,6 +67,10 @@ $(TARGETS): %: .FORCE @$(ECHO) "\t[CARGO ]:\t$@" @$(CARGO) build --manifest-path ./$@/Cargo.toml +$(BIN_TARGET_TESTS): %: .FORCE + @$(ECHO) "\t[BINTEST]:\t$@" + $(shell find $(subst -test,,$@) -name "*test.sh" -exec $(BASH) {} \;) + $(RELEASE_TARGETS): %: .FORCE @$(ECHO) "\t[RELEASE]:\t$(subst -release,,$@)" @$(CARGO) build --release --manifest-path ./$(subst -release,,$@)/Cargo.toml From 57114e159fc9d42126c30efbdb561ea0564074eb Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 10 Sep 2016 09:50:16 +0200 Subject: [PATCH 165/239] Execute tests by calling another Makefile --- Makefile | 3 ++- imag-link/tests/Makefile | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 imag-link/tests/Makefile diff --git a/Makefile b/Makefile index fcbf7cd8..46dfbaf5 100644 --- a/Makefile +++ b/Makefile @@ -4,6 +4,7 @@ bin = $@/target/debug/$@ doc-crate-toml=./.imag-documentation/Cargo.toml ECHO=$(shell which echo) -e +MAKE=$(shell which make) BASH=$(shell which bash) CARGO=$(shell which cargo) @@ -69,7 +70,7 @@ $(TARGETS): %: .FORCE $(BIN_TARGET_TESTS): %: .FORCE @$(ECHO) "\t[BINTEST]:\t$@" - $(shell find $(subst -test,,$@) -name "*test.sh" -exec $(BASH) {} \;) + find $(subst -test,,$@) -name "tests" -type d -exec $(MAKE) -j 1 -C {} \; $(RELEASE_TARGETS): %: .FORCE @$(ECHO) "\t[RELEASE]:\t$(subst -release,,$@)" diff --git a/imag-link/tests/Makefile b/imag-link/tests/Makefile new file mode 100644 index 00000000..2713587a --- /dev/null +++ b/imag-link/tests/Makefile @@ -0,0 +1,13 @@ +ECHO=$(shell which echo) -e +TARGETS=$(shell find -name "*test.sh" -type f) +BASH=$(shell which bash) + +all: $(TARGETS) + @$(ECHO) $(TARGETS) + +$(TARGETS): %: .FORCE + @$(ECHO) "\t[BASH ]:\t$@" + @$(BASH) $@ + +.FORCE: + From f9b4818607082c86c6585ff544a2613249634fd7 Mon Sep 17 00:00:00 2001 From: Julian Ganz Date: Sat, 17 Sep 2016 20:48:10 +0200 Subject: [PATCH 166/239] Add a convenience target for binary tests --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index 46dfbaf5..a049d285 100644 --- a/Makefile +++ b/Makefile @@ -50,6 +50,8 @@ release: $(RELEASE_TARGETS) imag-bin-release bin: $(BIN_TARGETS) imag-bin @$(ECHO) "\t[ALLBIN ]" +bin-test: $(BIN_TARGET_TESTS) + lib: $(LIB_TARGETS) @$(ECHO) "\t[ALLLIB ]" From 0ff53a69251dba2bd9ad3cbfab26d9c4b24083d7 Mon Sep 17 00:00:00 2001 From: Julian Ganz Date: Sat, 17 Sep 2016 20:48:38 +0200 Subject: [PATCH 167/239] Add general testing target --- Makefile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Makefile b/Makefile index a049d285..17ed07a2 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,8 @@ lib: $(LIB_TARGETS) lib-test: $(LIB_TARGETS_TEST) +test: bin-test lib-test + install: $(INSTALL_TARGETS) @$(ECHO) "\t[INSTALL]" From f6dc039554bb36d06d6e66288f410127675c871e Mon Sep 17 00:00:00 2001 From: Julian Ganz Date: Sat, 17 Sep 2016 20:56:12 +0200 Subject: [PATCH 168/239] Make the binary tests depend on the binaries --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 17ed07a2..ed9e1fb0 100644 --- a/Makefile +++ b/Makefile @@ -72,7 +72,7 @@ $(TARGETS): %: .FORCE @$(ECHO) "\t[CARGO ]:\t$@" @$(CARGO) build --manifest-path ./$@/Cargo.toml -$(BIN_TARGET_TESTS): %: .FORCE +$(BIN_TARGET_TESTS): %-test: % .FORCE @$(ECHO) "\t[BINTEST]:\t$@" find $(subst -test,,$@) -name "tests" -type d -exec $(MAKE) -j 1 -C {} \; From c5d660d3f7507a58bee3213c25b23e84697427ad Mon Sep 17 00:00:00 2001 From: Julian Ganz Date: Sun, 18 Sep 2016 10:51:12 +0200 Subject: [PATCH 169/239] Make "test" a postfix to library targets rather than a prefix --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ed9e1fb0..2ae6a9f7 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ LIBS=$(shell find -maxdepth 1 -name "libimag*" -type d) BIN_TARGETS=$(patsubst imag-%,,$(BINS)) BIN_TARGET_TESTS=$(foreach x,$(BIN_TARGETS),$(x)-test) LIB_TARGETS=$(LIBS) -LIB_TARGETS_TEST=$(foreach x,$(subst ./,,$(LIBS)),test-$(x)) +LIB_TARGETS_TEST=$(foreach x,$(subst ./,,$(LIBS)),$(x)-test) TARGETS=$(BIN_TARGETS) $(LIB_TARGETS) RELEASE_TARGETS=$(foreach x,$(TARGETS),$(x)-release) INSTALL_TARGETS=$(foreach x,$(BIN_TARGETS),$(x)-install) @@ -82,7 +82,7 @@ $(RELEASE_TARGETS): %: .FORCE $(LIB_TARGETS_TEST): %: .FORCE @$(ECHO) "\t[TEST ]:\t$@" - @$(CARGO) test --manifest-path ./$(subst test-,,$@)/Cargo.toml + @$(CARGO) test --manifest-path ./$(subst -test,,$@)/Cargo.toml $(INSTALL_TARGETS): %: .FORCE imag-bin-install @$(ECHO) "\t[INSTALL]:\t$(subst -install,,$@)" From d041d62d09afe859fc62a759541141826897a429 Mon Sep 17 00:00:00 2001 From: Julian Ganz Date: Sun, 18 Sep 2016 11:45:59 +0200 Subject: [PATCH 170/239] Replace invocation of "find" with test for a Makefile --- Makefile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 2ae6a9f7..a2cc3059 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,9 @@ $(TARGETS): %: .FORCE $(BIN_TARGET_TESTS): %-test: % .FORCE @$(ECHO) "\t[BINTEST]:\t$@" - find $(subst -test,,$@) -name "tests" -type d -exec $(MAKE) -j 1 -C {} \; + if [[ -f $(subst -test,,$@)/tests/Makefile ]]; then \ + $(MAKE) -C $(subst -test,,$@)/tests || exit 1;\ + fi; $(RELEASE_TARGETS): %: .FORCE @$(ECHO) "\t[RELEASE]:\t$(subst -release,,$@)" From b25aa29feed18953ba6ca115ffddf134779db01c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 19 Sep 2016 10:08:13 +0200 Subject: [PATCH 171/239] Fix make call in travis config --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 5982e293..6145fdd2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ script: done done else # $TEST_SUITE == "libraries" - make $(find . -maxdepth 1 -name "libimag*" -printf "test-%f ") + make $(find . -maxdepth 1 -name "libimag*" -printf "%f-test ") fi addons: From fb2300a799884db32979cad7cdf6785e172d95d8 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 19 Sep 2016 22:12:14 +0200 Subject: [PATCH 172/239] Add Makefile for testing imag-store --- imag-store/tests/Makefile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 imag-store/tests/Makefile diff --git a/imag-store/tests/Makefile b/imag-store/tests/Makefile new file mode 100644 index 00000000..c58562d7 --- /dev/null +++ b/imag-store/tests/Makefile @@ -0,0 +1,14 @@ +ECHO=$(shell which echo) -e +TARGETS=$(shell find -name "*test.sh" -type f) +BASH=$(shell which bash) + +all: $(TARGETS) + @$(ECHO) $(TARGETS) + +$(TARGETS): %: .FORCE + @$(ECHO) "\t[BASH ]:\t$@" + @$(BASH) $@ + +.FORCE: + + From e24619a08f192543a02e6003ef144e5443e8a156 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 19 Sep 2016 22:13:23 +0200 Subject: [PATCH 173/239] Minify travis script by using Makefile --- .travis.yml | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6145fdd2..7853d17f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -21,18 +21,9 @@ before_script: script: - | if [[ "$TEST_SUITE" == "binaries" ]]; then - make $(find . -maxdepth 1 -name "imag-*" -type d -printf "%f ") && \ - for d in $(find -name "Cargo.toml" | grep -vE "^./Cargo.toml$"); do - dir=$(dirname $d) - echo "--- Running test scripts ---" - for testsh in $(find $dir -iname "*test.sh"); do - echo "--- Running test script: '$testsh'" - bash $testsh || { echo "--- Test failed. Exiting"; exit 1; } - echo "--- Test script $testsh executed successfully" - done - done + make bin-test else # $TEST_SUITE == "libraries" - make $(find . -maxdepth 1 -name "libimag*" -printf "%f-test ") + make lib-test fi addons: From ba1df8bb4870fea69161d75d1c9082cd3cffd635 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 09:08:59 +0200 Subject: [PATCH 174/239] Remove unused config sections --- imagrc.toml | 28 ---------------------------- 1 file changed, 28 deletions(-) diff --git a/imagrc.toml b/imagrc.toml index de8d39ba..6e6463d4 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -38,34 +38,6 @@ mutable_hooks = false [store.hooks.stdhook_debug] aspect = "debug" -[store.hooks.stdhook_git_create] -aspect = "vcs" - -# Fail if the repository cannot be opened. If this is set to `false`, the error -# will be printed, but will not abort the store operation. `true` will print the -# error and abort the store action. -abort_on_repo_init_failure = true - -# Ensure to be on this branche before doing anything. -ensure_branch = "refs/heads/master" - -# Try to checkout the ensure_branch if it isn't checked out -try_checkout_ensure_branch = true - -[store.hooks.stdhook_git_retrieve] -aspect = "vcs" - -# Fail if the repository cannot be opened. If this is set to `false`, the error -# will be printed, but will not abort the store operation. `true` will print the -# error and abort the store action. -abort_on_repo_init_failure = true - -# Ensure to be on this branche before doing anything. -ensure_branch = "refs/heads/master" - -# Try to checkout the ensure_branch if it isn't checked out -try_checkout_ensure_branch = true - [store.hooks.stdhook_git_update] aspect = "vcs" From ece7fe061c0d030138b185a26efae34cff4d35c2 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 09:13:19 +0200 Subject: [PATCH 175/239] Add settings for enable/disable hook --- imagrc.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/imagrc.toml b/imagrc.toml index 6e6463d4..5dbbf9fc 100644 --- a/imagrc.toml +++ b/imagrc.toml @@ -41,6 +41,9 @@ aspect = "debug" [store.hooks.stdhook_git_update] aspect = "vcs" +# set to false to disable +enabled = true + # Fail if the repository cannot be opened. If this is set to `false`, the error # will be printed, but will not abort the store operation. `true` will print the # error and abort the store action. @@ -69,6 +72,9 @@ message = "Update" [store.hooks.stdhook_git_delete] aspect = "vcs" +# set to false to disable +enabled = true + # Fail if the repository cannot be opened. If this is set to `false`, the error # will be printed, but will not abort the store operation. `true` will print the # error and abort the store action. From d115e4ca8e0aac7a6a8726e495be1ccfc3da4c72 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 09:13:40 +0200 Subject: [PATCH 176/239] Add config helper to check whether hook is enabled or not --- libimagstorestdhook/src/vcs/git/config.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index db1a4d3d..25609cea 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -167,3 +167,9 @@ fn get_bool_cfg(cfg: Option<&Value>, name: &str, on_fail: bool, on_unavail: bool .unwrap_or(on_unavail) } +/// Check whether the hook is enabled or not. If the config is not there, the hook is _enabled_ by +/// default. +pub fn is_enabled(cfg: &Value) -> bool { + get_bool_cfg(Some(cfg), "enabled", true, true) +} + From fbd195db25bd496633b9c7d355f0c2c0f70b6935 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 09:13:56 +0200 Subject: [PATCH 177/239] DeleteHook: return Ok(()) if disabled --- libimagstorestdhook/src/vcs/git/delete.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index b44bf878..b5c0e56b 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -85,11 +85,17 @@ impl StoreIdAccessor for DeleteHook { use vcs::git::error::MapIntoHookError; use vcs::git::util::fetch_index; use vcs::git::config::abort_on_repo_init_err; + use vcs::git::config::is_enabled; use git2::{ADD_DEFAULT, STATUS_WT_DELETED, IndexMatchedPath}; debug!("[GIT DELETE HOOK]: {:?}", id); let action = StoreAction::Delete; + let cfg = try!(self.runtime.config_value_or_err(&action)); + + if !is_enabled(cfg) { + return Ok(()) + } if !self.runtime.has_repository() { debug!("[GIT DELETE HOOK]: Runtime has no repository..."); @@ -108,7 +114,6 @@ impl StoreIdAccessor for DeleteHook { } let _ = try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); - let cfg = try!(self.runtime.config_value_or_err(&action)); let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); From da8736d003d4090700a73ef9bcab717127aec061 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 09:14:07 +0200 Subject: [PATCH 178/239] UpdateHook: return Ok(()) if disabled --- libimagstorestdhook/src/vcs/git/update.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 25ada8a6..48fd7374 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -99,11 +99,17 @@ impl StoreIdAccessor for UpdateHook { use vcs::git::error::MapIntoHookError; use vcs::git::util::fetch_index; use vcs::git::config::abort_on_repo_init_err; + use vcs::git::config::is_enabled; use git2::{ADD_DEFAULT, STATUS_WT_NEW, STATUS_WT_MODIFIED, IndexMatchedPath}; debug!("[GIT UPDATE HOOK]: {:?}", id); let action = StoreAction::Update; + let cfg = try!(self.runtime.config_value_or_err(&action)); + + if !is_enabled(cfg) { + return Ok(()); + } if !self.runtime.has_repository() { debug!("[GIT UPDATE HOOK]: Runtime has no repository..."); @@ -122,7 +128,6 @@ impl StoreIdAccessor for UpdateHook { } let _ = try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); - let cfg = try!(self.runtime.config_value_or_err(&action)); let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); From b4fb226bb782ac62898c426f1aaf6777dc3dd1f6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 09:27:44 +0200 Subject: [PATCH 179/239] util: get_bool_cfg(): more debug output --- libimagstorestdhook/src/vcs/git/config.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index 25609cea..aca1652b 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -164,7 +164,10 @@ fn get_bool_cfg(cfg: Option<&Value>, name: &str, on_fail: bool, on_unavail: bool }, } }) - .unwrap_or(on_unavail) + .unwrap_or_else(|| { + debug!("No configuration to fetch {} from, assuming {}", name, on_unavail); + on_unavail + }) } /// Check whether the hook is enabled or not. If the config is not there, the hook is _enabled_ by From 52bb74da1593e0230cd6251a2a1d1b354a1b1fb4 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 09:28:13 +0200 Subject: [PATCH 180/239] util: get_bool_cfg(): Output with warn!() instead of debug!() --- libimagstorestdhook/src/vcs/git/config.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index aca1652b..f692edbb 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -159,13 +159,13 @@ fn get_bool_cfg(cfg: Option<&Value>, name: &str, on_fail: bool, on_unavail: bool on_fail }, None => { - debug!("No key '{}' - Assuming '{}'", name, on_unavail); + warn!("No key '{}' - Assuming '{}'", name, on_unavail); on_unavail }, } }) .unwrap_or_else(|| { - debug!("No configuration to fetch {} from, assuming {}", name, on_unavail); + warn!("No configuration to fetch {} from, assuming {}", name, on_unavail); on_unavail }) } From 128ed27bb820747c30b6a94cb57be3465cbc3451 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 10:27:39 +0200 Subject: [PATCH 181/239] Revert "Abort the execution of the UpdateHook if repo isnt dirty" This reverts commit b2a0758b1ad24e0707c40ab375396acdd3a3a325. --- libimagstorestdhook/src/vcs/git/update.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 25ada8a6..3d20a38c 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -126,13 +126,6 @@ impl StoreIdAccessor for UpdateHook { let repo = try!(self.runtime.repository(&action)); let mut index = try!(fetch_index(repo, &action)); - if !self.runtime.repo_is_dirty(&index) { - debug!("[GIT UPDATE HOOK]: Repository seems to be clean. I'm done."); - return Ok(()) - } else { - debug!("[GIT UPDATE HOOK]: Repository seems to be dirty. Continuing."); - } - let signature = try!( repo.signature() .map_err_into(GHEK::MkSignature) From 06c814d6e94fee466293507e9e3eb717dcf9da55 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 10:27:48 +0200 Subject: [PATCH 182/239] Revert "Add helper fn to check whether the repository WD is dirty" This reverts commit eb378d47c2c37e04f5c4130aec023142212c6abe. --- libimagstorestdhook/src/vcs/git/runtime.rs | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 0fb26326..76895935 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use git2::{Index, Repository}; +use git2::Repository; use toml::Value; use libimagerror::into::IntoError; @@ -155,25 +155,5 @@ impl Runtime { .map_dbg(|_| format!("[GIT {} HOOK]: Branch checked out", action.uppercase())) } - /// Check whether the WD is "dirty" - whether there is a diff to the repository - /// This function returns false if there is no `Repository` object in the `Runtime` - pub fn repo_is_dirty(&self, index: &Index) -> bool { - match self.repository.as_ref() { - Some(repo) => { - repo.diff_index_to_workdir(Some(index), None) - .map_dbg_str("Fetched diff: Index <-> WD") - .map_dbg_err_str("Failed to fetch diff: Index <-> WD") - .map(|diff| diff.deltas().count() != 0) - .unwrap_or(false) - }, - - None => { - debug!("No repository: Cannot fetch diff: Index <-> WD"); - false - } - } - - } - } From 9dc4054a92f01343df61ef28a6b21b24d064b377 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 15:16:22 +0200 Subject: [PATCH 183/239] Add debug output on file status --- libimagstorestdhook/src/vcs/git/update.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 833d6879..065191c7 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -157,6 +157,9 @@ impl StoreIdAccessor for UpdateHook { .map_into_hook_error() ); + debug!("File status: STATUS_WT_NEW = {}", file_status.contains(STATUS_WT_NEW)); + debug!("File status: STATUS_WT_MODIFIED = {}", file_status.contains(STATUS_WT_MODIFIED)); + let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { if file_status.contains(STATUS_WT_NEW) || file_status.contains(STATUS_WT_MODIFIED) { debug!("[GIT CREATE HOOK]: File is modified/new: {}", path.display()); From 5085d752084541522350c324997e36e3cd6ee509 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Sep 2016 15:18:51 +0200 Subject: [PATCH 184/239] Return if the file is not new and not modified --- libimagstorestdhook/src/vcs/git/update.rs | 33 ++++++++++++++--------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index 065191c7..fc8d451b 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -129,6 +129,26 @@ impl StoreIdAccessor for UpdateHook { let _ = try!(self.runtime.ensure_cfg_branch_is_checked_out(&action)); let repo = try!(self.runtime.repository(&action)); + + let file_status = try!( + repo + .status_file(id.local()) + .map_dbg_err_str("Failed to fetch file status") + .map_dbg_err(|e| format!("\t-> {:?}", e)) + .map_dbg_str("[GIT UPDATE HOOK]: Fetched file status") + .map_err_into(GHEK::RepositoryFileStatusError) + .map_into_hook_error() + ); + + debug!("File status: STATUS_WT_NEW = {}", file_status.contains(STATUS_WT_NEW)); + debug!("File status: STATUS_WT_MODIFIED = {}", file_status.contains(STATUS_WT_MODIFIED)); + + if !file_status.contains(STATUS_WT_NEW) && !file_status.contains(STATUS_WT_MODIFIED) { + // File seems to be unmodified and not new. This means that the file is already + // committed and we can return here. + return Ok(()) + } + let mut index = try!(fetch_index(repo, &action)); let signature = try!( @@ -147,19 +167,6 @@ impl StoreIdAccessor for UpdateHook { .map_into_hook_error() ); - let file_status = try!( - repo - .status_file(id.local()) - .map_dbg_err_str("Failed to fetch file status") - .map_dbg_err(|e| format!("\t-> {:?}", e)) - .map_dbg_str("[GIT UPDATE HOOK]: Fetched file status") - .map_err_into(GHEK::RepositoryFileStatusError) - .map_into_hook_error() - ); - - debug!("File status: STATUS_WT_NEW = {}", file_status.contains(STATUS_WT_NEW)); - debug!("File status: STATUS_WT_MODIFIED = {}", file_status.contains(STATUS_WT_MODIFIED)); - let cb = &mut |path: &Path, _matched_spec: &[u8]| -> i32 { if file_status.contains(STATUS_WT_NEW) || file_status.contains(STATUS_WT_MODIFIED) { debug!("[GIT CREATE HOOK]: File is modified/new: {}", path.display()); From f98afd4b01e97467b74fa68f65bbd92ce471bbe6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 21 Sep 2016 16:49:12 +0200 Subject: [PATCH 185/239] Move dependencies --- imag-diary/Cargo.toml | 3 --- imag-diary/src/main.rs | 1 - libimagdiary/Cargo.toml | 3 +++ libimagdiary/src/lib.rs | 1 + 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/imag-diary/Cargo.toml b/imag-diary/Cargo.toml index 2d0df647..618b16e6 100644 --- a/imag-diary/Cargo.toml +++ b/imag-diary/Cargo.toml @@ -21,9 +21,6 @@ path = "../libimagentryedit" [dependencies.libimagentrylist] path = "../libimagentrylist" -[dependencies.libimagentryview] -path = "../libimagentryview" - [dependencies.libimagerror] path = "../libimagerror" diff --git a/imag-diary/src/main.rs b/imag-diary/src/main.rs index 7a34f1ef..42b02fe0 100644 --- a/imag-diary/src/main.rs +++ b/imag-diary/src/main.rs @@ -21,7 +21,6 @@ extern crate chrono; extern crate libimagdiary; extern crate libimagentryedit; extern crate libimagentrylist; -extern crate libimagentryview; extern crate libimaginteraction; extern crate libimagrt; extern crate libimagstore; diff --git a/libimagdiary/Cargo.toml b/libimagdiary/Cargo.toml index 5ac1b268..3f921ade 100644 --- a/libimagdiary/Cargo.toml +++ b/libimagdiary/Cargo.toml @@ -27,3 +27,6 @@ path = "../libimagrt" [dependencies.libimagentryedit] path = "../libimagentryedit" +[dependencies.libimagentryview] +path = "../libimagentryview" + diff --git a/libimagdiary/src/lib.rs b/libimagdiary/src/lib.rs index 5af7eb50..b668a48d 100644 --- a/libimagdiary/src/lib.rs +++ b/libimagdiary/src/lib.rs @@ -26,6 +26,7 @@ extern crate itertools; #[macro_use] extern crate libimagutil; #[macro_use] extern crate libimagerror; extern crate libimagentryedit; +extern crate libimagentryview; extern crate libimagrt; module_entry_path_mod!("diary"); From 8e331f1f083e912f689e5ebd8a8c39b8e5d1a895 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 21 Sep 2016 16:45:23 +0200 Subject: [PATCH 186/239] Move viewer implementation for imag-diary to libimagdiary --- imag-diary/src/view.rs | 27 +++++++---------------- libimagdiary/src/error.rs | 3 ++- libimagdiary/src/lib.rs | 2 ++ libimagdiary/src/viewer.rs | 45 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 57 insertions(+), 20 deletions(-) create mode 100644 libimagdiary/src/viewer.rs diff --git a/imag-diary/src/view.rs b/imag-diary/src/view.rs index 742bc262..444c7131 100644 --- a/imag-diary/src/view.rs +++ b/imag-diary/src/view.rs @@ -1,30 +1,19 @@ use libimagdiary::diary::Diary; -use libimagentryview::viewer::Viewer; -use libimagentryview::builtin::plain::PlainViewer; +use libimagdiary::viewer::DiaryViewer as DV; use libimagrt::runtime::Runtime; -use libimagerror::trace::trace_error; +use libimagerror::trace::MapErrTrace; use libimagutil::warn_exit::warn_exit; use util::get_diary_name; pub fn view(rt: &Runtime) { let diaryname = get_diary_name(rt).unwrap_or_else(|| warn_exit("No diary name", 1)); - let diary = Diary::open(rt.store(), &diaryname[..]); - let show_header = rt.cli().subcommand_matches("view").unwrap().is_present("show-header"); + let diary = Diary::open(rt.store(), &diaryname[..]); + let hdr = rt.cli().subcommand_matches("view").unwrap().is_present("show-header"); - match diary.entries() { - Ok(entries) => { - let pv = PlainViewer::new(show_header); - for entry in entries.into_iter().filter_map(Result::ok) { - let id = entry.diary_id(); - println!("{} :\n", id); - if let Err(e) = pv.view_entry(&entry) { - trace_error(&e); - }; - println!("\n---\n"); - } - }, - Err(e) => trace_error(&e), - } + diary.entries() + .and_then(|entries| DV::new(hdr).view_entries(entries.into_iter().filter_map(Result::ok))) + .map_err_trace() + .ok(); } diff --git a/libimagdiary/src/error.rs b/libimagdiary/src/error.rs index 5cb37915..9ad53604 100644 --- a/libimagdiary/src/error.rs +++ b/libimagdiary/src/error.rs @@ -7,7 +7,8 @@ generate_error_module!( DiaryEditError => "Cannot edit diary entry", PathConversionError => "Error while converting paths internally", EntryNotInDiary => "Entry not in Diary", - IOError => "IO Error" + IOError => "IO Error", + ViewError => "Error viewing diary entry" ); ); diff --git a/libimagdiary/src/lib.rs b/libimagdiary/src/lib.rs index b668a48d..1a808283 100644 --- a/libimagdiary/src/lib.rs +++ b/libimagdiary/src/lib.rs @@ -39,3 +39,5 @@ pub mod is_in_diary; pub mod entry; pub mod iter; pub mod result; +pub mod viewer; + diff --git a/libimagdiary/src/viewer.rs b/libimagdiary/src/viewer.rs new file mode 100644 index 00000000..63c4f030 --- /dev/null +++ b/libimagdiary/src/viewer.rs @@ -0,0 +1,45 @@ +//! A diary viewer built on libimagentryview. + +use entry::Entry; +use error::DiaryErrorKind as DEK; +use error::MapErrInto; +use result::Result; + +use libimagentryview::viewer::Viewer; +use libimagentryview::builtin::plain::PlainViewer; + +/// This viewer does _not_ implement libimagentryview::viewer::Viewer because we need to be able to +/// call some diary-type specific functions on the entries passed to this. +/// +/// This type is mainly just written to be constructed-called-deleted in one go: +/// +/// ```ignore +/// DiaryViewer::new(show_header).view_entries(entries); +/// ``` +/// +pub struct DiaryViewer(PlainViewer); + +impl DiaryViewer { + + pub fn new(show_header: bool) -> DiaryViewer { + DiaryViewer(PlainViewer::new(show_header)) + } + + /// View all entries from the iterator, or stop immediately if an error occurs, returning that + /// error. + pub fn view_entries<'a, I: Iterator>>(&self, entries: I) -> Result<()> { + for entry in entries { + let id = entry.diary_id(); + println!("{} :\n", id); + let _ = try!(self.0 + .view_entry(&entry) + .map_err_into(DEK::ViewError) + .map_err_into(DEK::IOError)); + println!("\n---\n"); + } + + Ok(()) + } + +} + From 2b2116fb95daa7bfa941ebd46c3a7c9b110c5288 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 21 Sep 2016 17:07:23 +0200 Subject: [PATCH 187/239] View in stdout if not specified otherwise --- imag-view/src/main.rs | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/imag-view/src/main.rs b/imag-view/src/main.rs index ae9d5d29..76a6474b 100644 --- a/imag-view/src/main.rs +++ b/imag-view/src/main.rs @@ -48,14 +48,6 @@ fn main() { let view_header = rt.cli().is_present("view-header"); let view_content = rt.cli().is_present("view-content"); - let scmd = match rt.cli().subcommand_matches("view-in") { - None => { - debug!("No commandline call"); - exit(1); // we can afford not-executing destructors here - } - Some(s) => s, - }; - let entry = match rt.store().get(PathBuf::from(entry_id)) { Ok(Some(fle)) => fle, Ok(None) => { @@ -68,19 +60,27 @@ fn main() { }; let res = { - if scmd.is_present("view-in-stdout") { - } else if scmd.is_present("view-in-ui") { - warn!("Viewing in UI is currently not supported, switch to stdout"); - } else if scmd.is_present("view-in-browser") { - warn!("Viewing in browser is currently not supported, switch to stdout"); - } else if scmd.is_present("view-in-texteditor") { - if let Err(e) = Editor::new(&rt, &entry).show() { - error!("Cannot view in editor: {}", e); - trace_error_exit(&e, 1); - } - } else if scmd.is_present("view-in-custom") { - warn!("Viewing in custom is currently not supported, switch to stdout"); - } + match rt.cli().subcommand_matches("view-in") { + None => { + debug!("No commandline call"); + debug!("Assuming to view in cli (stdout)"); + }, + Some(s) => { + if s.is_present("view-in-stdout") { + } else if s.is_present("view-in-ui") { + warn!("Viewing in UI is currently not supported, switch to stdout"); + } else if s.is_present("view-in-browser") { + warn!("Viewing in browser is currently not supported, switch to stdout"); + } else if s.is_present("view-in-texteditor") { + if let Err(e) = Editor::new(&rt, &entry).show() { + error!("Cannot view in editor: {}", e); + trace_error_exit(&e, 1); + } + } else if s.is_present("view-in-custom") { + warn!("Viewing in custom is currently not supported, switch to stdout"); + } + }, + }; StdoutViewer::new(view_header, view_content).view_entry(&entry) }; From 352bccde51b20f6d77de4a68b9ae3fffd3e8a1b7 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 21 Sep 2016 17:19:37 +0200 Subject: [PATCH 188/239] Respecify view-in-editor argument As we use the `--editor` flag in the Runtime, we should not override it here. By passing `--editor foo` one can override the editor application-wide, the argument is now `--in-editor` therefor. --- imag-view/src/ui.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/imag-view/src/ui.rs b/imag-view/src/ui.rs index b1081e86..d498d795 100644 --- a/imag-view/src/ui.rs +++ b/imag-view/src/ui.rs @@ -50,12 +50,11 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .value_name("BROWSER")) .arg(Arg::with_name("view-in-texteditor") - .long("editor") + .long("in-editor") .short("e") - .takes_value(true) // optional, which editor + .takes_value(false) .required(false) - .help("View content in $EDITOR") - .value_name("EDITOR")) + .help("View content in $EDITOR (can be passed via --editor)")) .arg(Arg::with_name("view-in-custom") .long("custom") From 6a5c5e8449cdd097b6f0af301662ab5ba7603afd Mon Sep 17 00:00:00 2001 From: mario Date: Sat, 24 Sep 2016 10:52:09 +0200 Subject: [PATCH 189/239] Add the targets for the imag-binary to respective collector targets --- Makefile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index a2cc3059..a2ecf28e 100644 --- a/Makefile +++ b/Makefile @@ -21,7 +21,7 @@ INSTALL_TARGETS=$(foreach x,$(BIN_TARGETS),$(x)-install) UPDATE_TARGETS=$(foreach x,$(TARGETS),$(x)-update) CLEAN_TARGETS=$(foreach x,$(TARGETS),$(x)-clean) -all: $(TARGETS) +all: $(TARGETS) imag-bin @$(ECHO) "\t[ALL ]" imag-bin: @@ -59,10 +59,10 @@ lib-test: $(LIB_TARGETS_TEST) test: bin-test lib-test -install: $(INSTALL_TARGETS) +install: $(INSTALL_TARGETS) imag-bin-install @$(ECHO) "\t[INSTALL]" -update: $(UPDATE_TARGETS) +update: $(UPDATE_TARGETS) imag-bin-update @$(ECHO) "\t[UPDATE ]" clean: $(CLEAN_TARGETS) imag-bin-clean From 8e2ad8178d1b4c75da8386c91a3662dc15b319ed Mon Sep 17 00:00:00 2001 From: mario Date: Sat, 24 Sep 2016 10:58:11 +0200 Subject: [PATCH 190/239] Fix imag-bin-release --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index a2ecf28e..ac4cbb2f 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ imag-bin: imag-bin-release: @$(ECHO) "\t[IMAG ][RELEASE]" - @$(CARGO) release --manifest-path ./bin/Cargo.toml + @$(CARGO) build --release --manifest-path ./bin/Cargo.toml imag-bin-update: @$(ECHO) "\t[IMAG ][UPDATE ]" From 8c68d2210de2a82e6ed0f7b8125fc5b0b205f2c2 Mon Sep 17 00:00:00 2001 From: mario Date: Sat, 24 Sep 2016 11:01:00 +0200 Subject: [PATCH 191/239] Add `sort` for always same build order --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ac4cbb2f..344dc11a 100644 --- a/Makefile +++ b/Makefile @@ -8,8 +8,8 @@ MAKE=$(shell which make) BASH=$(shell which bash) CARGO=$(shell which cargo) -BINS=$(shell find -maxdepth 1 -name "imag-*" -type d) -LIBS=$(shell find -maxdepth 1 -name "libimag*" -type d) +BINS=$(shell find -maxdepth 1 -name "imag-*" -type d | sort) +LIBS=$(shell find -maxdepth 1 -name "libimag*" -type d | sort) BIN_TARGETS=$(patsubst imag-%,,$(BINS)) BIN_TARGET_TESTS=$(foreach x,$(BIN_TARGETS),$(x)-test) From 7a23097b00edd98f33db2b10da7d6707a51b65f1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 27 Sep 2016 20:12:18 +0200 Subject: [PATCH 192/239] Add dependencies --- libimagutil/Cargo.toml | 1 + libimagutil/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libimagutil/Cargo.toml b/libimagutil/Cargo.toml index 87be5306..b7a20fc0 100644 --- a/libimagutil/Cargo.toml +++ b/libimagutil/Cargo.toml @@ -4,6 +4,7 @@ version = "0.2.0" authors = ["Matthias Beyer "] [dependencies] +url = "1.1" lazy_static = "0.1.15" log = "0.3" regex = "0.1" diff --git a/libimagutil/src/lib.rs b/libimagutil/src/lib.rs index c0026c6f..901f7f5c 100644 --- a/libimagutil/src/lib.rs +++ b/libimagutil/src/lib.rs @@ -16,6 +16,7 @@ #[macro_use] extern crate lazy_static; #[macro_use] extern crate log; extern crate regex; +extern crate url; extern crate tempfile; #[macro_use] mod log_result; From 719e49271cd0abf4f0e06874b7aafc8192707ee0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 27 Sep 2016 20:12:47 +0200 Subject: [PATCH 193/239] Add module: cli_validators --- libimagutil/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/libimagutil/src/lib.rs b/libimagutil/src/lib.rs index 901f7f5c..ac1801f7 100644 --- a/libimagutil/src/lib.rs +++ b/libimagutil/src/lib.rs @@ -20,6 +20,7 @@ extern crate url; extern crate tempfile; #[macro_use] mod log_result; +pub mod cli_validators; pub mod debug_result; pub mod edit; pub mod info_result; From 7482ffb5b3c75cd2508983ad40574cb1833fbe50 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 27 Sep 2016 20:13:51 +0200 Subject: [PATCH 194/239] Add deps --- libimagutil/Cargo.toml | 1 + libimagutil/src/lib.rs | 1 + 2 files changed, 2 insertions(+) diff --git a/libimagutil/Cargo.toml b/libimagutil/Cargo.toml index b7a20fc0..61dd88e7 100644 --- a/libimagutil/Cargo.toml +++ b/libimagutil/Cargo.toml @@ -5,6 +5,7 @@ authors = ["Matthias Beyer "] [dependencies] url = "1.1" +boolinator = "2.4.0" lazy_static = "0.1.15" log = "0.3" regex = "0.1" diff --git a/libimagutil/src/lib.rs b/libimagutil/src/lib.rs index ac1801f7..72e6b29a 100644 --- a/libimagutil/src/lib.rs +++ b/libimagutil/src/lib.rs @@ -17,6 +17,7 @@ #[macro_use] extern crate log; extern crate regex; extern crate url; +extern crate boolinator; extern crate tempfile; #[macro_use] mod log_result; From 11490b232c71e3ee03d8f8c424902465fb3f7ae3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 27 Sep 2016 20:18:13 +0200 Subject: [PATCH 195/239] Add implementation for validators --- libimagutil/src/cli_validators.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 libimagutil/src/cli_validators.rs diff --git a/libimagutil/src/cli_validators.rs b/libimagutil/src/cli_validators.rs new file mode 100644 index 00000000..20c4f0b8 --- /dev/null +++ b/libimagutil/src/cli_validators.rs @@ -0,0 +1,26 @@ +//! Functions to be used for clap::Arg::validator() +//! to validate arguments + +use std::path::PathBuf; +use boolinator::Boolinator; + +pub fn is_file(s: String) -> Result<(), String> { + PathBuf::from(s.clone()).is_file().as_result((), format!("Not a File: {}", s)) +} + +pub fn is_directory(s: String) -> Result<(), String> { + PathBuf::from(s.clone()).is_dir().as_result((), format!("Not a Directory: {}", s)) +} + +pub fn is_integer(s: String) -> Result<(), String> { + use std::str::FromStr; + + let i : Result = FromStr::from_str(&s); + i.map(|_| ()).map_err(|_| format!("Not an integer: {}", s)) +} + +pub fn is_url(s: String) -> Result<(), String> { + use url::Url; + Url::parse(&s).map(|_| ()).map_err(|_| format!("Not a URL: {}", s)) +} + From 6999f95c4d7653b9c44960a9cb54b8675f428269 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 28 Sep 2016 19:44:23 +0200 Subject: [PATCH 196/239] imag-bookmark: Validate URLs --- imag-bookmark/src/ui.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imag-bookmark/src/ui.rs b/imag-bookmark/src/ui.rs index 701cdbba..6c49ba72 100644 --- a/imag-bookmark/src/ui.rs +++ b/imag-bookmark/src/ui.rs @@ -1,6 +1,7 @@ use clap::{Arg, App, SubCommand}; use libimagentrytag::ui::tag_add_arg; +use libimagutil::cli_validators::*; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app @@ -22,6 +23,7 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .required(true) .multiple(true) .value_name("URL") + .validator(is_url) .help("Add this URL, multiple possible")) .arg(tag_add_arg()) ) @@ -44,6 +46,7 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .required(true) .multiple(true) .value_name("URL") + .validator(is_url) .help("Remove these urls, regex supported")) ) From d6f705dc9036bcb9777530aa259c83ff0e11293d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 28 Sep 2016 19:51:21 +0200 Subject: [PATCH 197/239] Add is_tag clap validator helper --- libimagutil/src/cli_validators.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libimagutil/src/cli_validators.rs b/libimagutil/src/cli_validators.rs index 20c4f0b8..ed102ca5 100644 --- a/libimagutil/src/cli_validators.rs +++ b/libimagutil/src/cli_validators.rs @@ -24,3 +24,12 @@ pub fn is_url(s: String) -> Result<(), String> { Url::parse(&s).map(|_| ()).map_err(|_| format!("Not a URL: {}", s)) } +pub fn is_tag(s: String) -> Result<(), String> { + use regex::Regex; + lazy_static! { static ref TAG_RE : Regex = Regex::new("[:alpha:][:word:]*").unwrap(); } + + TAG_RE + .is_match(&s) + .as_result((), format!("Not a valid Tag: '{}' - Valid is [a-zA-Z][0-9a-zA-Z]*", s)) +} + From da439e60e996c8eac0ff07c4fe8c74e368991a3a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 28 Sep 2016 19:53:59 +0200 Subject: [PATCH 198/239] Add documentation what a valid tag is --- doc/src/04020-module-tag.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/src/04020-module-tag.md b/doc/src/04020-module-tag.md index 9e644efd..08c66ecf 100644 --- a/doc/src/04020-module-tag.md +++ b/doc/src/04020-module-tag.md @@ -2,6 +2,8 @@ The Tagging module. +A valid tag matches the regex `[a-zA-Z][0-9a-zA-Z]*`. + ### Description From 3d06933860f9286ef6117f43e7fc8aca9615c843 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 28 Sep 2016 19:55:57 +0200 Subject: [PATCH 199/239] Add is_tag validator --- libimagentrytag/src/ui.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libimagentrytag/src/ui.rs b/libimagentrytag/src/ui.rs index e74b1ac9..497eb596 100644 --- a/libimagentrytag/src/ui.rs +++ b/libimagentrytag/src/ui.rs @@ -2,6 +2,8 @@ use clap::{Arg, ArgMatches, App, SubCommand}; use tag::Tag; +use libimagutil::cli_validators::is_tag; + /// Generates a `clap::SubCommand` to be integrated in the commandline-ui builder for building a /// "tags --add foo --remove bar" subcommand to do tagging action. pub fn tag_subcommand<'a, 'b>() -> App<'a, 'b> { @@ -20,6 +22,7 @@ pub fn tag_add_arg<'a, 'b>() -> Arg<'a, 'b> { .takes_value(true) .value_name("tags") .multiple(true) + .validator(is_tag) .help("Add tags, seperated by comma or by specifying multiple times") } @@ -30,6 +33,7 @@ pub fn tag_remove_arg<'a, 'b>() -> Arg<'a, 'b> { .takes_value(true) .value_name("tags") .multiple(true) + .validator(is_tag) .help("Remove tags, seperated by comma or by specifying multiple times") } @@ -57,6 +61,7 @@ pub fn tag_argument<'a, 'b>() -> Arg<'a, 'b> { .long("tags") .takes_value(true) .multiple(true) + .validator(is_tag) .help("Add or remove tags, prefixed by '+' (for adding) or '-' (for removing)") } From f8ed44c1e70fd6c2c1c8d6b021f4e43d7c99c17a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 30 Sep 2016 10:47:11 +0200 Subject: [PATCH 200/239] Add cli validator: is_existing_path() --- libimagutil/src/cli_validators.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libimagutil/src/cli_validators.rs b/libimagutil/src/cli_validators.rs index ed102ca5..068d5834 100644 --- a/libimagutil/src/cli_validators.rs +++ b/libimagutil/src/cli_validators.rs @@ -4,6 +4,10 @@ use std::path::PathBuf; use boolinator::Boolinator; +pub fn is_existing_path(s: String) -> Result<(), String> { + PathBuf::from(s.clone()).exists().as_result((), format!("Not a File or Directory: {}", s)) +} + pub fn is_file(s: String) -> Result<(), String> { PathBuf::from(s.clone()).is_file().as_result((), format!("Not a File: {}", s)) } From 4d2ac38ceb2a7fcbf47b8f6d5e7857602b4a3cc0 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 30 Sep 2016 10:47:38 +0200 Subject: [PATCH 201/239] imag-ref: Use validator is_existing_path --- imag-ref/src/ui.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/imag-ref/src/ui.rs b/imag-ref/src/ui.rs index e884c90f..37cbb799 100644 --- a/imag-ref/src/ui.rs +++ b/imag-ref/src/ui.rs @@ -1,5 +1,7 @@ use clap::{Arg, App, SubCommand}; +use libimagutil::cli_validators::is_existing_path; + pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { app .subcommand(SubCommand::with_name("add") @@ -11,6 +13,7 @@ pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { .takes_value(true) .required(true) .help("The path of the file") + .validator(is_existing_path) .value_name("PATH")) .arg(Arg::with_name("track-content") .long("content-hash") From e0d4744b4b03528e904dfb8174bfe449a725ee53 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 202/239] bin: Add copyright notice to all files --- bin/src/main.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/bin/src/main.rs b/bin/src/main.rs index 71d56820..4d258e19 100644 --- a/bin/src/main.rs +++ b/bin/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + extern crate crossbeam; extern crate clap; #[macro_use] extern crate version; From 49c852fa67f1450e6147d0ce08740336f4415040 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 203/239] imag-bookmark: Add copyright notice to all files --- imag-bookmark/src/main.rs | 19 +++++++++++++++++++ imag-bookmark/src/ui.rs | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/imag-bookmark/src/main.rs b/imag-bookmark/src/main.rs index 06490c24..b23b7211 100644 --- a/imag-bookmark/src/main.rs +++ b/imag-bookmark/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + extern crate clap; #[macro_use] extern crate log; #[macro_use] extern crate version; diff --git a/imag-bookmark/src/ui.rs b/imag-bookmark/src/ui.rs index 701cdbba..76b883de 100644 --- a/imag-bookmark/src/ui.rs +++ b/imag-bookmark/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, App, SubCommand}; use libimagentrytag::ui::tag_add_arg; From adf10e187a7413d45c438a3d27938fc3c9970fec Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 204/239] imag-counter: Add copyright notice to all files --- imag-counter/src/create.rs | 19 +++++++++++++++++++ imag-counter/src/delete.rs | 19 +++++++++++++++++++ imag-counter/src/interactive.rs | 19 +++++++++++++++++++ imag-counter/src/list.rs | 19 +++++++++++++++++++ imag-counter/src/main.rs | 19 +++++++++++++++++++ imag-counter/src/ui.rs | 19 +++++++++++++++++++ 6 files changed, 114 insertions(+) diff --git a/imag-counter/src/create.rs b/imag-counter/src/create.rs index 9b455df5..9ef66387 100644 --- a/imag-counter/src/create.rs +++ b/imag-counter/src/create.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::str::FromStr; use libimagrt::runtime::Runtime; diff --git a/imag-counter/src/delete.rs b/imag-counter/src/delete.rs index 92bb543f..8a358284 100644 --- a/imag-counter/src/delete.rs +++ b/imag-counter/src/delete.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagrt::runtime::Runtime; use libimagerror::trace::trace_error_exit; use libimagcounter::counter::Counter; diff --git a/imag-counter/src/interactive.rs b/imag-counter/src/interactive.rs index d37a0c05..c4a8fa65 100644 --- a/imag-counter/src/interactive.rs +++ b/imag-counter/src/interactive.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::collections::BTreeMap; use std::fmt::{Display, Formatter, Error}; use std::io::Write; diff --git a/imag-counter/src/list.rs b/imag-counter/src/list.rs index d18ae9b1..d8d3e86e 100644 --- a/imag-counter/src/list.rs +++ b/imag-counter/src/list.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagrt::runtime::Runtime; use libimagerror::trace::{MapErrTrace, trace_error}; use libimagcounter::counter::Counter; diff --git a/imag-counter/src/main.rs b/imag-counter/src/main.rs index c83bba0a..35a22441 100644 --- a/imag-counter/src/main.rs +++ b/imag-counter/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/imag-counter/src/ui.rs b/imag-counter/src/ui.rs index 2218076e..2b928dd8 100644 --- a/imag-counter/src/ui.rs +++ b/imag-counter/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, App, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { From f79b8c000b8142dcb5376362b5702271dbcd7a96 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 205/239] imag-diary: Add copyright notice to all files --- imag-diary/src/create.rs | 19 +++++++++++++++++++ imag-diary/src/delete.rs | 19 +++++++++++++++++++ imag-diary/src/edit.rs | 19 +++++++++++++++++++ imag-diary/src/list.rs | 19 +++++++++++++++++++ imag-diary/src/main.rs | 19 +++++++++++++++++++ imag-diary/src/ui.rs | 19 +++++++++++++++++++ imag-diary/src/util.rs | 19 +++++++++++++++++++ imag-diary/src/view.rs | 19 +++++++++++++++++++ 8 files changed, 152 insertions(+) diff --git a/imag-diary/src/create.rs b/imag-diary/src/create.rs index c715cfaf..78f679a7 100644 --- a/imag-diary/src/create.rs +++ b/imag-diary/src/create.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::process::exit; use libimagdiary::diary::Diary; diff --git a/imag-diary/src/delete.rs b/imag-diary/src/delete.rs index aec5a8eb..7325047b 100644 --- a/imag-diary/src/delete.rs +++ b/imag-diary/src/delete.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use chrono::naive::datetime::NaiveDateTime; use libimagdiary::diary::Diary; diff --git a/imag-diary/src/edit.rs b/imag-diary/src/edit.rs index 6c87d130..beed8c05 100644 --- a/imag-diary/src/edit.rs +++ b/imag-diary/src/edit.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use chrono::naive::datetime::NaiveDateTime; use libimagdiary::diary::Diary; diff --git a/imag-diary/src/list.rs b/imag-diary/src/list.rs index bae95ce4..4f1abc51 100644 --- a/imag-diary/src/list.rs +++ b/imag-diary/src/list.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagdiary::diary::Diary; use libimagdiary::error::DiaryErrorKind as DEK; use libimagdiary::error::MapErrInto; diff --git a/imag-diary/src/main.rs b/imag-diary/src/main.rs index 42b02fe0..71e00cd6 100644 --- a/imag-diary/src/main.rs +++ b/imag-diary/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/imag-diary/src/ui.rs b/imag-diary/src/ui.rs index a38060bd..91712fb6 100644 --- a/imag-diary/src/ui.rs +++ b/imag-diary/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, ArgGroup, App, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { diff --git a/imag-diary/src/util.rs b/imag-diary/src/util.rs index 956062be..25498085 100644 --- a/imag-diary/src/util.rs +++ b/imag-diary/src/util.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagrt::runtime::Runtime; pub fn get_diary_name(rt: &Runtime) -> Option { diff --git a/imag-diary/src/view.rs b/imag-diary/src/view.rs index 444c7131..041a1fe0 100644 --- a/imag-diary/src/view.rs +++ b/imag-diary/src/view.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagdiary::diary::Diary; use libimagdiary::viewer::DiaryViewer as DV; use libimagrt::runtime::Runtime; From 3f85cf21c181950c3b8f79e5e83124cde276d038 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 206/239] .imag-documentation: Add copyright notice to all files --- .imag-documentation/src/lib.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/.imag-documentation/src/lib.rs b/.imag-documentation/src/lib.rs index 2f50c33f..63eafb5f 100644 --- a/.imag-documentation/src/lib.rs +++ b/.imag-documentation/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + //! # imag //! //! This is the _developer_ documentation for the imag personal information management suite for the From 0fc0471af6e05eb7787c0b4b479372094b1f9d7c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 207/239] imag-link: Add copyright notice to all files --- imag-link/src/main.rs | 19 +++++++++++++++++++ imag-link/src/ui.rs | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/imag-link/src/main.rs b/imag-link/src/main.rs index a30758e5..6734c3d4 100644 --- a/imag-link/src/main.rs +++ b/imag-link/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/imag-link/src/ui.rs b/imag-link/src/ui.rs index b54c4982..4edb6bd1 100644 --- a/imag-link/src/ui.rs +++ b/imag-link/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, ArgGroup, App, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { From 73d67b1f182b834834ccaf0e8cc19046e610eee3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 208/239] imag-notes: Add copyright notice to all files --- imag-notes/src/main.rs | 19 +++++++++++++++++++ imag-notes/src/ui.rs | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/imag-notes/src/main.rs b/imag-notes/src/main.rs index 475847c0..dd24607c 100644 --- a/imag-notes/src/main.rs +++ b/imag-notes/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + extern crate clap; #[macro_use] extern crate log; extern crate semver; diff --git a/imag-notes/src/ui.rs b/imag-notes/src/ui.rs index 1c115853..906c5524 100644 --- a/imag-notes/src/ui.rs +++ b/imag-notes/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, App, SubCommand}; use libimagentrytag::ui::tag_argument; From ba50cb6ff62d7e8c71003d137dded4fc30be2105 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 209/239] imag-ref: Add copyright notice to all files --- imag-ref/src/main.rs | 19 +++++++++++++++++++ imag-ref/src/ui.rs | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/imag-ref/src/main.rs b/imag-ref/src/main.rs index fd29a4a6..1d3a5a13 100644 --- a/imag-ref/src/main.rs +++ b/imag-ref/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #[macro_use] extern crate log; #[macro_use] extern crate version; extern crate semver; diff --git a/imag-ref/src/ui.rs b/imag-ref/src/ui.rs index e884c90f..8fc952d0 100644 --- a/imag-ref/src/ui.rs +++ b/imag-ref/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, App, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { From 598d8617a1bd9c7a404ac6795b9457ef67517227 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 210/239] imag-store: Add copyright notice to all files --- imag-store/src/create.rs | 19 +++++++++++++++++++ imag-store/src/delete.rs | 19 +++++++++++++++++++ imag-store/src/error.rs | 19 +++++++++++++++++++ imag-store/src/get.rs | 19 +++++++++++++++++++ imag-store/src/main.rs | 19 +++++++++++++++++++ imag-store/src/retrieve.rs | 19 +++++++++++++++++++ imag-store/src/ui.rs | 19 +++++++++++++++++++ imag-store/src/update.rs | 19 +++++++++++++++++++ imag-store/src/util.rs | 19 +++++++++++++++++++ imag-store/src/verify.rs | 19 +++++++++++++++++++ 10 files changed, 190 insertions(+) diff --git a/imag-store/src/create.rs b/imag-store/src/create.rs index 0380ddf5..cfdbd01b 100644 --- a/imag-store/src/create.rs +++ b/imag-store/src/create.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use std::io::stdin; use std::fs::OpenOptions; diff --git a/imag-store/src/delete.rs b/imag-store/src/delete.rs index 885a089c..1413de77 100644 --- a/imag-store/src/delete.rs +++ b/imag-store/src/delete.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use libimagrt::runtime::Runtime; diff --git a/imag-store/src/error.rs b/imag-store/src/error.rs index ae9162f0..bc248ade 100644 --- a/imag-store/src/error.rs +++ b/imag-store/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(StoreError, StoreErrorKind, BackendError => "Backend Error", diff --git a/imag-store/src/get.rs b/imag-store/src/get.rs index 1302b763..0c2aa132 100644 --- a/imag-store/src/get.rs +++ b/imag-store/src/get.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use libimagrt::runtime::Runtime; diff --git a/imag-store/src/main.rs b/imag-store/src/main.rs index 56c46241..7d2f46e9 100644 --- a/imag-store/src/main.rs +++ b/imag-store/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/imag-store/src/retrieve.rs b/imag-store/src/retrieve.rs index 41f8e936..4d17e817 100644 --- a/imag-store/src/retrieve.rs +++ b/imag-store/src/retrieve.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use clap::ArgMatches; diff --git a/imag-store/src/ui.rs b/imag-store/src/ui.rs index a317a445..fc493c9c 100644 --- a/imag-store/src/ui.rs +++ b/imag-store/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, App, ArgGroup, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { diff --git a/imag-store/src/update.rs b/imag-store/src/update.rs index 87279dc0..bdcfb6de 100644 --- a/imag-store/src/update.rs +++ b/imag-store/src/update.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::ops::DerefMut; use std::path::PathBuf; diff --git a/imag-store/src/util.rs b/imag-store/src/util.rs index 197f2846..8e7002c9 100644 --- a/imag-store/src/util.rs +++ b/imag-store/src/util.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::borrow::Cow; use std::collections::btree_map::{BTreeMap, Entry}; use std::str::Split; diff --git a/imag-store/src/verify.rs b/imag-store/src/verify.rs index b22d5909..6c9cb703 100644 --- a/imag-store/src/verify.rs +++ b/imag-store/src/verify.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagrt::runtime::Runtime; use libimagutil::warn_exit::warn_exit; From 56e537673cb62e58254a6513d766d1f5d37970ff Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 211/239] imag-tag: Add copyright notice to all files --- imag-tag/src/main.rs | 19 +++++++++++++++++++ imag-tag/src/ui.rs | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/imag-tag/src/main.rs b/imag-tag/src/main.rs index 92d3b7f3..3e8d7daa 100644 --- a/imag-tag/src/main.rs +++ b/imag-tag/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + extern crate clap; #[macro_use] extern crate log; extern crate semver; diff --git a/imag-tag/src/ui.rs b/imag-tag/src/ui.rs index 1355344a..ee9b6feb 100644 --- a/imag-tag/src/ui.rs +++ b/imag-tag/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, App, ArgGroup, SubCommand}; use libimagentrytag::ui::{tag_add_arg, tag_remove_arg}; From ae60c9251394f7f45197bd1f0f4cdb7e0e42ede1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 212/239] imag-todo: Add copyright notice to all files --- imag-todo/src/main.rs | 19 +++++++++++++++++++ imag-todo/src/ui.rs | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/imag-todo/src/main.rs b/imag-todo/src/main.rs index a5ca650e..bcdae191 100644 --- a/imag-todo/src/main.rs +++ b/imag-todo/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + extern crate clap; extern crate glob; #[macro_use] extern crate log; diff --git a/imag-todo/src/ui.rs b/imag-todo/src/ui.rs index f781673e..795c76c6 100644 --- a/imag-todo/src/ui.rs +++ b/imag-todo/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, App, ArgGroup, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { From 6808400008371e53c31451e182fd72e05253fea3 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 213/239] imag-view: Add copyright notice to all files --- imag-view/src/editor.rs | 19 +++++++++++++++++++ imag-view/src/main.rs | 19 +++++++++++++++++++ imag-view/src/ui.rs | 19 +++++++++++++++++++ 3 files changed, 57 insertions(+) diff --git a/imag-view/src/editor.rs b/imag-view/src/editor.rs index 6a60b007..bbd255f7 100644 --- a/imag-view/src/editor.rs +++ b/imag-view/src/editor.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::FileLockEntry; use libimagrt::runtime::Runtime; use libimagentryview::builtin::editor::EditorView; diff --git a/imag-view/src/main.rs b/imag-view/src/main.rs index 76a6474b..b9f1d059 100644 --- a/imag-view/src/main.rs +++ b/imag-view/src/main.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/imag-view/src/ui.rs b/imag-view/src/ui.rs index d498d795..dd165850 100644 --- a/imag-view/src/ui.rs +++ b/imag-view/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, App, ArgGroup, SubCommand}; pub fn build_ui<'a>(app: App<'a, 'a>) -> App<'a, 'a> { From d9a0709499e85a5f29fe43263fa364c041546765 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 214/239] libimagbookmark: Add copyright notice to all files --- libimagbookmark/src/collection.rs | 19 +++++++++++++++++++ libimagbookmark/src/error.rs | 19 +++++++++++++++++++ libimagbookmark/src/lib.rs | 19 +++++++++++++++++++ libimagbookmark/src/link.rs | 19 +++++++++++++++++++ libimagbookmark/src/result.rs | 19 +++++++++++++++++++ 5 files changed, 95 insertions(+) diff --git a/libimagbookmark/src/collection.rs b/libimagbookmark/src/collection.rs index b2cde9ef..59d95e72 100644 --- a/libimagbookmark/src/collection.rs +++ b/libimagbookmark/src/collection.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + //! BookmarkCollection module //! //! A BookmarkCollection is nothing more than a simple store entry. One can simply call functions diff --git a/libimagbookmark/src/error.rs b/libimagbookmark/src/error.rs index 79849d9e..9b52a169 100644 --- a/libimagbookmark/src/error.rs +++ b/libimagbookmark/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(BookmarkError, BookmarkErrorKind, StoreReadError => "Store read error", diff --git a/libimagbookmark/src/lib.rs b/libimagbookmark/src/lib.rs index bc98b061..6b7de0dc 100644 --- a/libimagbookmark/src/lib.rs +++ b/libimagbookmark/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagbookmark/src/link.rs b/libimagbookmark/src/link.rs index 078d45d7..1da91c8a 100644 --- a/libimagbookmark/src/link.rs +++ b/libimagbookmark/src/link.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::ops::{Deref, DerefMut}; use result::Result; diff --git a/libimagbookmark/src/result.rs b/libimagbookmark/src/result.rs index 265fec97..780a8035 100644 --- a/libimagbookmark/src/result.rs +++ b/libimagbookmark/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::BookmarkError; From df2736d7d81d83e5c3350f5c556a17f7d26977b6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 215/239] libimagcounter: Add copyright notice to all files --- libimagcounter/src/counter.rs | 19 +++++++++++++++++++ libimagcounter/src/error.rs | 19 +++++++++++++++++++ libimagcounter/src/lib.rs | 19 +++++++++++++++++++ libimagcounter/src/result.rs | 19 +++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/libimagcounter/src/counter.rs b/libimagcounter/src/counter.rs index e6a6e309..12bc0a93 100644 --- a/libimagcounter/src/counter.rs +++ b/libimagcounter/src/counter.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::ops::DerefMut; use toml::Value; diff --git a/libimagcounter/src/error.rs b/libimagcounter/src/error.rs index e151c407..c886d901 100644 --- a/libimagcounter/src/error.rs +++ b/libimagcounter/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(CounterError, CounterErrorKind, StoreIdError => "StoreId error", diff --git a/libimagcounter/src/lib.rs b/libimagcounter/src/lib.rs index 75340ad6..3ad74aa9 100644 --- a/libimagcounter/src/lib.rs +++ b/libimagcounter/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagcounter/src/result.rs b/libimagcounter/src/result.rs index 91a26599..e24b90c9 100644 --- a/libimagcounter/src/result.rs +++ b/libimagcounter/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::CounterError; From 5182d8e2ad1c07d7d056852bdd4ca4057a257641 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 216/239] libimagdiary: Add copyright notice to all files --- libimagdiary/src/config.rs | 19 +++++++++++++++++++ libimagdiary/src/diary.rs | 19 +++++++++++++++++++ libimagdiary/src/diaryid.rs | 19 +++++++++++++++++++ libimagdiary/src/entry.rs | 19 +++++++++++++++++++ libimagdiary/src/error.rs | 19 +++++++++++++++++++ libimagdiary/src/is_in_diary.rs | 19 +++++++++++++++++++ libimagdiary/src/iter.rs | 19 +++++++++++++++++++ libimagdiary/src/lib.rs | 19 +++++++++++++++++++ libimagdiary/src/result.rs | 19 +++++++++++++++++++ libimagdiary/src/viewer.rs | 19 +++++++++++++++++++ 10 files changed, 190 insertions(+) diff --git a/libimagdiary/src/config.rs b/libimagdiary/src/config.rs index 93749289..b2e976a6 100644 --- a/libimagdiary/src/config.rs +++ b/libimagdiary/src/config.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use toml::Value; use libimagrt::runtime::Runtime; diff --git a/libimagdiary/src/diary.rs b/libimagdiary/src/diary.rs index de8571f9..1a19b052 100644 --- a/libimagdiary/src/diary.rs +++ b/libimagdiary/src/diary.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::cmp::Ordering; use libimagstore::store::Store; diff --git a/libimagdiary/src/diaryid.rs b/libimagdiary/src/diaryid.rs index 74c78309..ad91ccf3 100644 --- a/libimagdiary/src/diaryid.rs +++ b/libimagdiary/src/diaryid.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::convert::Into; use std::fmt::{Display, Formatter, Error as FmtError}; diff --git a/libimagdiary/src/entry.rs b/libimagdiary/src/entry.rs index c042fd91..0148b59d 100644 --- a/libimagdiary/src/entry.rs +++ b/libimagdiary/src/entry.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::ops::Deref; use std::ops::DerefMut; diff --git a/libimagdiary/src/error.rs b/libimagdiary/src/error.rs index 9ad53604..b6dc2bfd 100644 --- a/libimagdiary/src/error.rs +++ b/libimagdiary/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(DiaryError, DiaryErrorKind, StoreWriteError => "Error writing store", diff --git a/libimagdiary/src/is_in_diary.rs b/libimagdiary/src/is_in_diary.rs index 2b9d3fc7..09228072 100644 --- a/libimagdiary/src/is_in_diary.rs +++ b/libimagdiary/src/is_in_diary.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use libimagstore::storeid::StoreId; diff --git a/libimagdiary/src/iter.rs b/libimagdiary/src/iter.rs index 5146e5a7..73f180d2 100644 --- a/libimagdiary/src/iter.rs +++ b/libimagdiary/src/iter.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::fmt::{Debug, Formatter, Error as FmtError}; use std::result::Result as RResult; diff --git a/libimagdiary/src/lib.rs b/libimagdiary/src/lib.rs index 1a808283..f6756225 100644 --- a/libimagdiary/src/lib.rs +++ b/libimagdiary/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( dead_code, non_camel_case_types, diff --git a/libimagdiary/src/result.rs b/libimagdiary/src/result.rs index 5348c44b..b4f5f382 100644 --- a/libimagdiary/src/result.rs +++ b/libimagdiary/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::DiaryError; diff --git a/libimagdiary/src/viewer.rs b/libimagdiary/src/viewer.rs index 63c4f030..93b155a7 100644 --- a/libimagdiary/src/viewer.rs +++ b/libimagdiary/src/viewer.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + //! A diary viewer built on libimagentryview. use entry::Entry; From 8836c083923087f55ec34948180851c987c07d05 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 217/239] libimagentryedit: Add copyright notice to all files --- libimagentryedit/src/edit.rs | 19 +++++++++++++++++++ libimagentryedit/src/error.rs | 19 +++++++++++++++++++ libimagentryedit/src/lib.rs | 19 +++++++++++++++++++ libimagentryedit/src/result.rs | 19 +++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/libimagentryedit/src/edit.rs b/libimagentryedit/src/edit.rs index 08e2bfb4..f83c51c5 100644 --- a/libimagentryedit/src/edit.rs +++ b/libimagentryedit/src/edit.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::ops::DerefMut; use libimagerror::into::IntoError; diff --git a/libimagentryedit/src/error.rs b/libimagentryedit/src/error.rs index 776a51fb..478d5d2c 100644 --- a/libimagentryedit/src/error.rs +++ b/libimagentryedit/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(EditError, EditErrorKind, IOError => "IO Error", diff --git a/libimagentryedit/src/lib.rs b/libimagentryedit/src/lib.rs index d0a26038..00013d5e 100644 --- a/libimagentryedit/src/lib.rs +++ b/libimagentryedit/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #[macro_use] extern crate libimagerror; extern crate libimagstore; extern crate libimagrt; diff --git a/libimagentryedit/src/result.rs b/libimagentryedit/src/result.rs index 7e58f0fe..1d917c05 100644 --- a/libimagentryedit/src/result.rs +++ b/libimagentryedit/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::EditError; From ed8e479bc6235834b30d09ae8d9019d884db37fe Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 218/239] libimagentryfilter: Add copyright notice to all files --- libimagentryfilter/src/builtin/bool_filter.rs | 19 +++++++++++++++++++ .../src/builtin/content/grep.rs | 19 +++++++++++++++++++ .../src/builtin/content/length/is_over.rs | 19 +++++++++++++++++++ .../src/builtin/content/length/is_under.rs | 19 +++++++++++++++++++ .../src/builtin/content/length/mod.rs | 19 +++++++++++++++++++ libimagentryfilter/src/builtin/content/mod.rs | 19 +++++++++++++++++++ .../src/builtin/header/field_eq.rs | 19 +++++++++++++++++++ .../src/builtin/header/field_exists.rs | 19 +++++++++++++++++++ .../src/builtin/header/field_grep.rs | 19 +++++++++++++++++++ .../src/builtin/header/field_gt.rs | 19 +++++++++++++++++++ .../src/builtin/header/field_isempty.rs | 19 +++++++++++++++++++ .../src/builtin/header/field_istype.rs | 19 +++++++++++++++++++ .../src/builtin/header/field_lt.rs | 19 +++++++++++++++++++ .../src/builtin/header/field_path.rs | 19 +++++++++++++++++++ .../src/builtin/header/field_predicate.rs | 19 +++++++++++++++++++ libimagentryfilter/src/builtin/header/mod.rs | 19 +++++++++++++++++++ .../src/builtin/header/version/eq.rs | 19 +++++++++++++++++++ .../src/builtin/header/version/gt.rs | 19 +++++++++++++++++++ .../src/builtin/header/version/lt.rs | 19 +++++++++++++++++++ .../src/builtin/header/version/mod.rs | 19 +++++++++++++++++++ .../src/builtin/header/version/range.rs | 19 +++++++++++++++++++ libimagentryfilter/src/builtin/mod.rs | 19 +++++++++++++++++++ libimagentryfilter/src/cli.rs | 19 +++++++++++++++++++ libimagentryfilter/src/lib.rs | 19 +++++++++++++++++++ libimagentryfilter/src/tags/mod.rs | 19 +++++++++++++++++++ 25 files changed, 475 insertions(+) diff --git a/libimagentryfilter/src/builtin/bool_filter.rs b/libimagentryfilter/src/builtin/bool_filter.rs index a25f8159..e903e341 100644 --- a/libimagentryfilter/src/builtin/bool_filter.rs +++ b/libimagentryfilter/src/builtin/bool_filter.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use filters::filter::Filter; diff --git a/libimagentryfilter/src/builtin/content/grep.rs b/libimagentryfilter/src/builtin/content/grep.rs index de8ade9b..02039fba 100644 --- a/libimagentryfilter/src/builtin/content/grep.rs +++ b/libimagentryfilter/src/builtin/content/grep.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use filters::filter::Filter; use regex::Regex; use regex::Error as RError; diff --git a/libimagentryfilter/src/builtin/content/length/is_over.rs b/libimagentryfilter/src/builtin/content/length/is_over.rs index 1ef51ab9..96f22da4 100644 --- a/libimagentryfilter/src/builtin/content/length/is_over.rs +++ b/libimagentryfilter/src/builtin/content/length/is_over.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use filters::filter::Filter; use libimagstore::store::Entry; diff --git a/libimagentryfilter/src/builtin/content/length/is_under.rs b/libimagentryfilter/src/builtin/content/length/is_under.rs index 5ae7fe7f..a365438e 100644 --- a/libimagentryfilter/src/builtin/content/length/is_under.rs +++ b/libimagentryfilter/src/builtin/content/length/is_under.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use filters::filter::Filter; use libimagstore::store::Entry; diff --git a/libimagentryfilter/src/builtin/content/length/mod.rs b/libimagentryfilter/src/builtin/content/length/mod.rs index 94121f96..2ebb18cb 100644 --- a/libimagentryfilter/src/builtin/content/length/mod.rs +++ b/libimagentryfilter/src/builtin/content/length/mod.rs @@ -1,2 +1,21 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub mod is_over; pub mod is_under; diff --git a/libimagentryfilter/src/builtin/content/mod.rs b/libimagentryfilter/src/builtin/content/mod.rs index b0ec6127..2ccbdf66 100644 --- a/libimagentryfilter/src/builtin/content/mod.rs +++ b/libimagentryfilter/src/builtin/content/mod.rs @@ -1,2 +1,21 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub mod grep; pub mod length; diff --git a/libimagentryfilter/src/builtin/header/field_eq.rs b/libimagentryfilter/src/builtin/header/field_eq.rs index 457f42b0..f10f3d0f 100644 --- a/libimagentryfilter/src/builtin/header/field_eq.rs +++ b/libimagentryfilter/src/builtin/header/field_eq.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_exists.rs b/libimagentryfilter/src/builtin/header/field_exists.rs index 721b7e0e..9999b3df 100644 --- a/libimagentryfilter/src/builtin/header/field_exists.rs +++ b/libimagentryfilter/src/builtin/header/field_exists.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_grep.rs b/libimagentryfilter/src/builtin/header/field_grep.rs index ce312b02..799fee68 100644 --- a/libimagentryfilter/src/builtin/header/field_grep.rs +++ b/libimagentryfilter/src/builtin/header/field_grep.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use regex::Regex; use toml::Value; diff --git a/libimagentryfilter/src/builtin/header/field_gt.rs b/libimagentryfilter/src/builtin/header/field_gt.rs index 02786901..2c1bcf89 100644 --- a/libimagentryfilter/src/builtin/header/field_gt.rs +++ b/libimagentryfilter/src/builtin/header/field_gt.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_isempty.rs b/libimagentryfilter/src/builtin/header/field_isempty.rs index e8ea94c3..d243d78f 100644 --- a/libimagentryfilter/src/builtin/header/field_isempty.rs +++ b/libimagentryfilter/src/builtin/header/field_isempty.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_istype.rs b/libimagentryfilter/src/builtin/header/field_istype.rs index 13e6b325..889c8321 100644 --- a/libimagentryfilter/src/builtin/header/field_istype.rs +++ b/libimagentryfilter/src/builtin/header/field_istype.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_lt.rs b/libimagentryfilter/src/builtin/header/field_lt.rs index 9f6fae9a..0316bf82 100644 --- a/libimagentryfilter/src/builtin/header/field_lt.rs +++ b/libimagentryfilter/src/builtin/header/field_lt.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/field_path.rs b/libimagentryfilter/src/builtin/header/field_path.rs index b61f32b9..42ba65aa 100644 --- a/libimagentryfilter/src/builtin/header/field_path.rs +++ b/libimagentryfilter/src/builtin/header/field_path.rs @@ -1 +1,20 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub type FieldPath = String; diff --git a/libimagentryfilter/src/builtin/header/field_predicate.rs b/libimagentryfilter/src/builtin/header/field_predicate.rs index 1415b901..361ed0fe 100644 --- a/libimagentryfilter/src/builtin/header/field_predicate.rs +++ b/libimagentryfilter/src/builtin/header/field_predicate.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use builtin::header::field_path::FieldPath; diff --git a/libimagentryfilter/src/builtin/header/mod.rs b/libimagentryfilter/src/builtin/header/mod.rs index 0d27f5b4..cb363c24 100644 --- a/libimagentryfilter/src/builtin/header/mod.rs +++ b/libimagentryfilter/src/builtin/header/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub mod field_eq; pub mod field_exists; pub mod field_grep; diff --git a/libimagentryfilter/src/builtin/header/version/eq.rs b/libimagentryfilter/src/builtin/header/version/eq.rs index acf75495..ac805a68 100644 --- a/libimagentryfilter/src/builtin/header/version/eq.rs +++ b/libimagentryfilter/src/builtin/header/version/eq.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use semver::Version; use toml::Value; diff --git a/libimagentryfilter/src/builtin/header/version/gt.rs b/libimagentryfilter/src/builtin/header/version/gt.rs index cc5dcade..daded755 100644 --- a/libimagentryfilter/src/builtin/header/version/gt.rs +++ b/libimagentryfilter/src/builtin/header/version/gt.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use semver::Version; use toml::Value; diff --git a/libimagentryfilter/src/builtin/header/version/lt.rs b/libimagentryfilter/src/builtin/header/version/lt.rs index b7232c4c..02c35cd3 100644 --- a/libimagentryfilter/src/builtin/header/version/lt.rs +++ b/libimagentryfilter/src/builtin/header/version/lt.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use semver::Version; use toml::Value; diff --git a/libimagentryfilter/src/builtin/header/version/mod.rs b/libimagentryfilter/src/builtin/header/version/mod.rs index a2e86826..e214e329 100644 --- a/libimagentryfilter/src/builtin/header/version/mod.rs +++ b/libimagentryfilter/src/builtin/header/version/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub mod eq; pub mod gt; pub mod lt; diff --git a/libimagentryfilter/src/builtin/header/version/range.rs b/libimagentryfilter/src/builtin/header/version/range.rs index 66ccbcd8..59f3a1d5 100644 --- a/libimagentryfilter/src/builtin/header/version/range.rs +++ b/libimagentryfilter/src/builtin/header/version/range.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use semver::Version; use libimagstore::store::Entry; diff --git a/libimagentryfilter/src/builtin/mod.rs b/libimagentryfilter/src/builtin/mod.rs index be547532..68c819bc 100644 --- a/libimagentryfilter/src/builtin/mod.rs +++ b/libimagentryfilter/src/builtin/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub mod content; pub mod header; diff --git a/libimagentryfilter/src/cli.rs b/libimagentryfilter/src/cli.rs index e69de29b..ee8b8381 100644 --- a/libimagentryfilter/src/cli.rs +++ b/libimagentryfilter/src/cli.rs @@ -0,0 +1,19 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + diff --git a/libimagentryfilter/src/lib.rs b/libimagentryfilter/src/lib.rs index 03cb114d..a481d125 100644 --- a/libimagentryfilter/src/lib.rs +++ b/libimagentryfilter/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagentryfilter/src/tags/mod.rs b/libimagentryfilter/src/tags/mod.rs index 162e9824..cef11e5e 100644 --- a/libimagentryfilter/src/tags/mod.rs +++ b/libimagentryfilter/src/tags/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use libimagentrytag::tagable::Tagable; use libimagentrytag::tag::Tag; From 2db79ada71866f499c9fc89366eca87f8edebe70 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 219/239] libimagentrylink: Add copyright notice to all files --- libimagentrylink/src/error.rs | 19 +++++++++++++++++++ libimagentrylink/src/external.rs | 19 +++++++++++++++++++ libimagentrylink/src/internal.rs | 19 +++++++++++++++++++ libimagentrylink/src/lib.rs | 19 +++++++++++++++++++ libimagentrylink/src/result.rs | 19 +++++++++++++++++++ 5 files changed, 95 insertions(+) diff --git a/libimagentrylink/src/error.rs b/libimagentrylink/src/error.rs index 9c756c3b..7665da4d 100644 --- a/libimagentrylink/src/error.rs +++ b/libimagentrylink/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(LinkError, LinkErrorKind, EntryHeaderReadError => "Error while reading an entry header", diff --git a/libimagentrylink/src/external.rs b/libimagentrylink/src/external.rs index 45972bf5..f68028ff 100644 --- a/libimagentrylink/src/external.rs +++ b/libimagentrylink/src/external.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + /// External linking is a complex implementation to be able to serve a clean and easy-to-use /// interface. /// diff --git a/libimagentrylink/src/internal.rs b/libimagentrylink/src/internal.rs index 54d2b7de..f8320cd3 100644 --- a/libimagentrylink/src/internal.rs +++ b/libimagentrylink/src/internal.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::cmp::Ordering; use libimagstore::storeid::StoreId; diff --git a/libimagentrylink/src/lib.rs b/libimagentrylink/src/lib.rs index 804916fc..31442503 100644 --- a/libimagentrylink/src/lib.rs +++ b/libimagentrylink/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagentrylink/src/result.rs b/libimagentrylink/src/result.rs index 587c0cac..23e50363 100644 --- a/libimagentrylink/src/result.rs +++ b/libimagentrylink/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::LinkError; From f47ba140e6056fbdd3916adcc91f66666e4aa13f Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 220/239] libimagentrylist: Add copyright notice to all files --- libimagentrylist/src/cli.rs | 19 +++++++++++++++++++ libimagentrylist/src/error.rs | 19 +++++++++++++++++++ libimagentrylist/src/lib.rs | 19 +++++++++++++++++++ libimagentrylist/src/lister.rs | 19 +++++++++++++++++++ libimagentrylist/src/listers/core.rs | 19 +++++++++++++++++++ libimagentrylist/src/listers/line.rs | 19 +++++++++++++++++++ libimagentrylist/src/listers/mod.rs | 19 +++++++++++++++++++ libimagentrylist/src/listers/path.rs | 19 +++++++++++++++++++ libimagentrylist/src/listers/table.rs | 19 +++++++++++++++++++ libimagentrylist/src/result.rs | 19 +++++++++++++++++++ 10 files changed, 190 insertions(+) diff --git a/libimagentrylist/src/cli.rs b/libimagentrylist/src/cli.rs index 5a04a21a..b52a92fd 100644 --- a/libimagentrylist/src/cli.rs +++ b/libimagentrylist/src/cli.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, ArgMatches, App, SubCommand}; use libimagstore::store::FileLockEntry; diff --git a/libimagentrylist/src/error.rs b/libimagentrylist/src/error.rs index 32e19f43..9c3b1ccc 100644 --- a/libimagentrylist/src/error.rs +++ b/libimagentrylist/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(ListError, ListErrorKind, IOError => "IO Error", diff --git a/libimagentrylist/src/lib.rs b/libimagentrylist/src/lib.rs index 8c6b8869..ee97d72c 100644 --- a/libimagentrylist/src/lib.rs +++ b/libimagentrylist/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( dead_code, non_camel_case_types, diff --git a/libimagentrylist/src/lister.rs b/libimagentrylist/src/lister.rs index 80f86110..798061b8 100644 --- a/libimagentrylist/src/lister.rs +++ b/libimagentrylist/src/lister.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::FileLockEntry; use result::Result; diff --git a/libimagentrylist/src/listers/core.rs b/libimagentrylist/src/listers/core.rs index f2f83eea..733ba719 100644 --- a/libimagentrylist/src/listers/core.rs +++ b/libimagentrylist/src/listers/core.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::io::stdout; use std::io::Write; diff --git a/libimagentrylist/src/listers/line.rs b/libimagentrylist/src/listers/line.rs index 536d2039..66181542 100644 --- a/libimagentrylist/src/listers/line.rs +++ b/libimagentrylist/src/listers/line.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::io::stdout; use std::io::Write; diff --git a/libimagentrylist/src/listers/mod.rs b/libimagentrylist/src/listers/mod.rs index 4c43b657..78a6e8f7 100644 --- a/libimagentrylist/src/listers/mod.rs +++ b/libimagentrylist/src/listers/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub mod core; pub mod line; pub mod path; diff --git a/libimagentrylist/src/listers/path.rs b/libimagentrylist/src/listers/path.rs index cfe67b65..284ff1b3 100644 --- a/libimagentrylist/src/listers/path.rs +++ b/libimagentrylist/src/listers/path.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::io::stdout; use std::io::Write; diff --git a/libimagentrylist/src/listers/table.rs b/libimagentrylist/src/listers/table.rs index 231f708d..e9358ce3 100644 --- a/libimagentrylist/src/listers/table.rs +++ b/libimagentrylist/src/listers/table.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::io::stdout; use lister::Lister; diff --git a/libimagentrylist/src/result.rs b/libimagentrylist/src/result.rs index 729cce41..e29d7d34 100644 --- a/libimagentrylist/src/result.rs +++ b/libimagentrylist/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::ListError; From 82e39f427a92c001ead81aedeb8b02060120319b Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 221/239] libimagentrymarkdown: Add copyright notice to all files --- libimagentrymarkdown/src/error.rs | 19 +++++++++++++++++++ libimagentrymarkdown/src/html.rs | 19 +++++++++++++++++++ libimagentrymarkdown/src/lib.rs | 19 +++++++++++++++++++ libimagentrymarkdown/src/link.rs | 19 +++++++++++++++++++ libimagentrymarkdown/src/result.rs | 19 +++++++++++++++++++ 5 files changed, 95 insertions(+) diff --git a/libimagentrymarkdown/src/error.rs b/libimagentrymarkdown/src/error.rs index 3e42e21b..1186d5f3 100644 --- a/libimagentrymarkdown/src/error.rs +++ b/libimagentrymarkdown/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(MarkdownError, MarkdownErrorKind, MarkdownRenderError => "Markdown render error", diff --git a/libimagentrymarkdown/src/html.rs b/libimagentrymarkdown/src/html.rs index f9d251a8..e0a7b8b9 100644 --- a/libimagentrymarkdown/src/html.rs +++ b/libimagentrymarkdown/src/html.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use hoedown::{Markdown, Html as MdHtml}; use hoedown::renderer::html::Flags as HtmlFlags; use hoedown::renderer::Render; diff --git a/libimagentrymarkdown/src/lib.rs b/libimagentrymarkdown/src/lib.rs index d5d23410..d04680b7 100644 --- a/libimagentrymarkdown/src/lib.rs +++ b/libimagentrymarkdown/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagentrymarkdown/src/link.rs b/libimagentrymarkdown/src/link.rs index 8ac3500c..267ef344 100644 --- a/libimagentrymarkdown/src/link.rs +++ b/libimagentrymarkdown/src/link.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use error::MarkdownErrorKind as MEK; use result::Result; diff --git a/libimagentrymarkdown/src/result.rs b/libimagentrymarkdown/src/result.rs index 55aa68e5..f00a3122 100644 --- a/libimagentrymarkdown/src/result.rs +++ b/libimagentrymarkdown/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::MarkdownError; From 28c023dbc5dfdeb7b80dc9157887307106c0dc77 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 222/239] libimagentrytag: Add copyright notice to all files --- libimagentrytag/src/error.rs | 19 +++++++++++++++++++ libimagentrytag/src/exec.rs | 19 +++++++++++++++++++ libimagentrytag/src/lib.rs | 19 +++++++++++++++++++ libimagentrytag/src/result.rs | 19 +++++++++++++++++++ libimagentrytag/src/tag.rs | 19 +++++++++++++++++++ libimagentrytag/src/tagable.rs | 19 +++++++++++++++++++ libimagentrytag/src/ui.rs | 19 +++++++++++++++++++ libimagentrytag/src/util.rs | 19 +++++++++++++++++++ 8 files changed, 152 insertions(+) diff --git a/libimagentrytag/src/error.rs b/libimagentrytag/src/error.rs index 06f08797..579e3ce8 100644 --- a/libimagentrytag/src/error.rs +++ b/libimagentrytag/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(TagError, TagErrorKind, TagTypeError => "Entry Header Tag Type wrong", diff --git a/libimagentrytag/src/exec.rs b/libimagentrytag/src/exec.rs index 8ea45142..216e2c28 100644 --- a/libimagentrytag/src/exec.rs +++ b/libimagentrytag/src/exec.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::ArgMatches; use libimagstore::store::FileLockEntry; diff --git a/libimagentrytag/src/lib.rs b/libimagentrytag/src/lib.rs index 87e4fe87..d8931e40 100644 --- a/libimagentrytag/src/lib.rs +++ b/libimagentrytag/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagentrytag/src/result.rs b/libimagentrytag/src/result.rs index a01166ca..02d72766 100644 --- a/libimagentrytag/src/result.rs +++ b/libimagentrytag/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::TagError; diff --git a/libimagentrytag/src/tag.rs b/libimagentrytag/src/tag.rs index ec72161c..28ecd934 100644 --- a/libimagentrytag/src/tag.rs +++ b/libimagentrytag/src/tag.rs @@ -1,2 +1,21 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub type Tag = String; pub type TagSlice<'a> = &'a str; diff --git a/libimagentrytag/src/tagable.rs b/libimagentrytag/src/tagable.rs index df49f763..21e7c5ec 100644 --- a/libimagentrytag/src/tagable.rs +++ b/libimagentrytag/src/tagable.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::ops::Deref; use std::ops::DerefMut; diff --git a/libimagentrytag/src/ui.rs b/libimagentrytag/src/ui.rs index e74b1ac9..066f06da 100644 --- a/libimagentrytag/src/ui.rs +++ b/libimagentrytag/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::{Arg, ArgMatches, App, SubCommand}; use tag::Tag; diff --git a/libimagentrytag/src/util.rs b/libimagentrytag/src/util.rs index 16b76a1d..d0d31db2 100644 --- a/libimagentrytag/src/util.rs +++ b/libimagentrytag/src/util.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use regex::Regex; pub fn is_tag(s: &str) -> bool { From 6cd765f67b08e5dc4f3682c32eb226972a8ce27a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 223/239] libimagentryview: Add copyright notice to all files --- libimagentryview/src/builtin/editor.rs | 19 +++++++++++++++++++ libimagentryview/src/builtin/mod.rs | 19 +++++++++++++++++++ libimagentryview/src/builtin/plain.rs | 19 +++++++++++++++++++ libimagentryview/src/builtin/stdout.rs | 19 +++++++++++++++++++ libimagentryview/src/error.rs | 19 +++++++++++++++++++ libimagentryview/src/lib.rs | 19 +++++++++++++++++++ libimagentryview/src/result.rs | 19 +++++++++++++++++++ libimagentryview/src/viewer.rs | 19 +++++++++++++++++++ 8 files changed, 152 insertions(+) diff --git a/libimagentryview/src/builtin/editor.rs b/libimagentryview/src/builtin/editor.rs index d13c1fb4..259d4986 100644 --- a/libimagentryview/src/builtin/editor.rs +++ b/libimagentryview/src/builtin/editor.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use libimagrt::runtime::Runtime; use libimagentryedit::edit::edit_in_tmpfile; diff --git a/libimagentryview/src/builtin/mod.rs b/libimagentryview/src/builtin/mod.rs index 657f5e80..26d5b223 100644 --- a/libimagentryview/src/builtin/mod.rs +++ b/libimagentryview/src/builtin/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub mod editor; pub mod plain; pub mod stdout; diff --git a/libimagentryview/src/builtin/plain.rs b/libimagentryview/src/builtin/plain.rs index 02ff5fc8..d96f4604 100644 --- a/libimagentryview/src/builtin/plain.rs +++ b/libimagentryview/src/builtin/plain.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use viewer::Viewer; diff --git a/libimagentryview/src/builtin/stdout.rs b/libimagentryview/src/builtin/stdout.rs index 7f6a8b28..703281fd 100644 --- a/libimagentryview/src/builtin/stdout.rs +++ b/libimagentryview/src/builtin/stdout.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use toml::encode_str; diff --git a/libimagentryview/src/error.rs b/libimagentryview/src/error.rs index fbc31487..c471b3f3 100644 --- a/libimagentryview/src/error.rs +++ b/libimagentryview/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(ViewError, ViewErrorKind, Unknown => "Unknown view error", diff --git a/libimagentryview/src/lib.rs b/libimagentryview/src/lib.rs index 534b05f3..788eb49c 100644 --- a/libimagentryview/src/lib.rs +++ b/libimagentryview/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( dead_code, non_camel_case_types, diff --git a/libimagentryview/src/result.rs b/libimagentryview/src/result.rs index 4d5786fa..3650b1fe 100644 --- a/libimagentryview/src/result.rs +++ b/libimagentryview/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::ViewError; diff --git a/libimagentryview/src/viewer.rs b/libimagentryview/src/viewer.rs index 72ffbd7d..35763126 100644 --- a/libimagentryview/src/viewer.rs +++ b/libimagentryview/src/viewer.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagstore::store::Entry; use result::Result; From 4b2514e5a05480a710c851f88622f9737e8e168e Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 224/239] libimagerror: Add copyright notice to all files --- libimagerror/src/error_gen.rs | 19 +++++++++++++++++++ libimagerror/src/into.rs | 19 +++++++++++++++++++ libimagerror/src/lib.rs | 19 +++++++++++++++++++ libimagerror/src/trace.rs | 19 +++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/libimagerror/src/error_gen.rs b/libimagerror/src/error_gen.rs index 236251e0..e46ce184 100644 --- a/libimagerror/src/error_gen.rs +++ b/libimagerror/src/error_gen.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #[macro_export] macro_rules! generate_error_imports { () => { diff --git a/libimagerror/src/into.rs b/libimagerror/src/into.rs index a959abd4..bc3cfb41 100644 --- a/libimagerror/src/into.rs +++ b/libimagerror/src/into.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::error::Error; /// Trait to help converting Error kinds into Error instances diff --git a/libimagerror/src/lib.rs b/libimagerror/src/lib.rs index 34d4758c..5046ba5a 100644 --- a/libimagerror/src/lib.rs +++ b/libimagerror/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagerror/src/trace.rs b/libimagerror/src/trace.rs index 30687eeb..3fbc4faf 100644 --- a/libimagerror/src/trace.rs +++ b/libimagerror/src/trace.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::error::Error; use std::io::Write; use std::io::stderr; From 6b809a5a27cc234ed56ed263a313d5b1f57ce863 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 225/239] libimaginteraction: Add copyright notice to all files --- libimaginteraction/src/ask.rs | 19 +++++++++++++++++++ libimaginteraction/src/error.rs | 19 +++++++++++++++++++ libimaginteraction/src/filter.rs | 19 +++++++++++++++++++ libimaginteraction/src/lib.rs | 19 +++++++++++++++++++ libimaginteraction/src/result.rs | 19 +++++++++++++++++++ libimaginteraction/src/ui.rs | 19 +++++++++++++++++++ 6 files changed, 114 insertions(+) diff --git a/libimaginteraction/src/ask.rs b/libimaginteraction/src/ask.rs index b85ac837..30f4b26c 100644 --- a/libimaginteraction/src/ask.rs +++ b/libimaginteraction/src/ask.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + // functions to ask the user for data, with crate:spinner use std::io::stdin; diff --git a/libimaginteraction/src/error.rs b/libimaginteraction/src/error.rs index ff347f1c..5ac3b730 100644 --- a/libimaginteraction/src/error.rs +++ b/libimaginteraction/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(InteractionError, InteractionErrorKind, Unknown => "Unknown Error", diff --git a/libimaginteraction/src/filter.rs b/libimaginteraction/src/filter.rs index 875eb0ec..5869a529 100644 --- a/libimaginteraction/src/filter.rs +++ b/libimaginteraction/src/filter.rs @@ -1 +1,20 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + // A filter which uses crate:interactor to filter entries diff --git a/libimaginteraction/src/lib.rs b/libimaginteraction/src/lib.rs index b994ee21..07d458bd 100644 --- a/libimaginteraction/src/lib.rs +++ b/libimaginteraction/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimaginteraction/src/result.rs b/libimaginteraction/src/result.rs index f3d63482..8eeaf47b 100644 --- a/libimaginteraction/src/result.rs +++ b/libimaginteraction/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::InteractionError; diff --git a/libimaginteraction/src/ui.rs b/libimaginteraction/src/ui.rs index 850a537e..49c4619d 100644 --- a/libimaginteraction/src/ui.rs +++ b/libimaginteraction/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use clap::{Arg, ArgMatches}; From b34eb838e056160e0f461685386892cc0ea6f3d1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 226/239] libimagnotes: Add copyright notice to all files --- libimagnotes/src/error.rs | 19 +++++++++++++++++++ libimagnotes/src/lib.rs | 19 +++++++++++++++++++ libimagnotes/src/note.rs | 19 +++++++++++++++++++ libimagnotes/src/result.rs | 19 +++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/libimagnotes/src/error.rs b/libimagnotes/src/error.rs index bebed316..9fd51218 100644 --- a/libimagnotes/src/error.rs +++ b/libimagnotes/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(NoteError, NoteErrorKind, StoreWriteError => "Error writing store", diff --git a/libimagnotes/src/lib.rs b/libimagnotes/src/lib.rs index 7abc5eb3..10ef952b 100644 --- a/libimagnotes/src/lib.rs +++ b/libimagnotes/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( dead_code, non_camel_case_types, diff --git a/libimagnotes/src/note.rs b/libimagnotes/src/note.rs index 768b5607..2397948c 100644 --- a/libimagnotes/src/note.rs +++ b/libimagnotes/src/note.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::collections::BTreeMap; use std::ops::Deref; diff --git a/libimagnotes/src/result.rs b/libimagnotes/src/result.rs index df40d8c7..a11ba895 100644 --- a/libimagnotes/src/result.rs +++ b/libimagnotes/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::NoteError; From b08b53b056149ef8915a63d52ac189739e6ee185 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 227/239] libimagref: Add copyright notice to all files --- libimagref/src/error.rs | 19 +++++++++++++++++++ libimagref/src/flags.rs | 19 +++++++++++++++++++ libimagref/src/hasher.rs | 19 +++++++++++++++++++ libimagref/src/hashers/mod.rs | 19 +++++++++++++++++++ libimagref/src/hashers/nbytes.rs | 19 +++++++++++++++++++ libimagref/src/lib.rs | 19 +++++++++++++++++++ libimagref/src/lister.rs | 19 +++++++++++++++++++ libimagref/src/reference.rs | 19 +++++++++++++++++++ libimagref/src/result.rs | 19 +++++++++++++++++++ 9 files changed, 171 insertions(+) diff --git a/libimagref/src/error.rs b/libimagref/src/error.rs index b0aaacf3..b1e5e2c5 100644 --- a/libimagref/src/error.rs +++ b/libimagref/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(RefError, RefErrorKind, StoreReadError => "Store read error", diff --git a/libimagref/src/flags.rs b/libimagref/src/flags.rs index 00bfcf2b..11cd838d 100644 --- a/libimagref/src/flags.rs +++ b/libimagref/src/flags.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::collections::BTreeMap; use toml::Value; diff --git a/libimagref/src/hasher.rs b/libimagref/src/hasher.rs index fcdda5bd..d29502d2 100644 --- a/libimagref/src/hasher.rs +++ b/libimagref/src/hasher.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use std::io::Read; diff --git a/libimagref/src/hashers/mod.rs b/libimagref/src/hashers/mod.rs index c5c49799..eaa8de3f 100644 --- a/libimagref/src/hashers/mod.rs +++ b/libimagref/src/hashers/mod.rs @@ -1 +1,20 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub mod nbytes; diff --git a/libimagref/src/hashers/nbytes.rs b/libimagref/src/hashers/nbytes.rs index 66af0297..995e3dd8 100644 --- a/libimagref/src/hashers/nbytes.rs +++ b/libimagref/src/hashers/nbytes.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::io::Read; use std::path::PathBuf; use std::result::Result as RResult; diff --git a/libimagref/src/lib.rs b/libimagref/src/lib.rs index fb4814c9..402eac27 100644 --- a/libimagref/src/lib.rs +++ b/libimagref/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagref/src/lister.rs b/libimagref/src/lister.rs index 979984a2..326a764f 100644 --- a/libimagref/src/lister.rs +++ b/libimagref/src/lister.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::default::Default; use std::io::stdout; use std::io::Write; diff --git a/libimagref/src/reference.rs b/libimagref/src/reference.rs index 15a89734..63ca6a39 100644 --- a/libimagref/src/reference.rs +++ b/libimagref/src/reference.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + //! The Ref object is a helper over the link functionality, so one is able to create references to //! files outside of the imag store. diff --git a/libimagref/src/result.rs b/libimagref/src/result.rs index 097232d5..eefcec65 100644 --- a/libimagref/src/result.rs +++ b/libimagref/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use error::RefError; From 221b87d7fb1345053ab42a7fe45590a57e64ba65 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 228/239] libimagrt: Add copyright notice to all files --- libimagrt/src/configuration.rs | 19 +++++++++++++++++++ libimagrt/src/error.rs | 19 +++++++++++++++++++ libimagrt/src/lib.rs | 19 +++++++++++++++++++ libimagrt/src/logger.rs | 19 +++++++++++++++++++ libimagrt/src/runtime.rs | 19 +++++++++++++++++++ libimagrt/src/setup.rs | 19 +++++++++++++++++++ 6 files changed, 114 insertions(+) diff --git a/libimagrt/src/configuration.rs b/libimagrt/src/configuration.rs index 71056901..52e51b24 100644 --- a/libimagrt/src/configuration.rs +++ b/libimagrt/src/configuration.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use std::result::Result as RResult; use std::ops::Deref; diff --git a/libimagrt/src/error.rs b/libimagrt/src/error.rs index e5f26baa..388335af 100644 --- a/libimagrt/src/error.rs +++ b/libimagrt/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_imports!(); use std::io::Error as IOError; diff --git a/libimagrt/src/lib.rs b/libimagrt/src/lib.rs index 2aea566b..13c004ba 100644 --- a/libimagrt/src/lib.rs +++ b/libimagrt/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( dead_code, non_camel_case_types, diff --git a/libimagrt/src/logger.rs b/libimagrt/src/logger.rs index f5b6ad76..2e6244f8 100644 --- a/libimagrt/src/logger.rs +++ b/libimagrt/src/logger.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::io::Write; use std::io::stderr; diff --git a/libimagrt/src/runtime.rs b/libimagrt/src/runtime.rs index 3e8ed7d8..60f81d16 100644 --- a/libimagrt/src/runtime.rs +++ b/libimagrt/src/runtime.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use std::process::Command; use std::env; diff --git a/libimagrt/src/setup.rs b/libimagrt/src/setup.rs index 620a81cf..735a8883 100644 --- a/libimagrt/src/setup.rs +++ b/libimagrt/src/setup.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::App; use runtime::Runtime; From 6cc1a90870d097c8c841e178daa8750072158990 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 229/239] libimagstore: Add copyright notice to all files --- libimagstore/src/configuration.rs | 19 +++++++++++++++++++ libimagstore/src/error.rs | 19 +++++++++++++++++++ libimagstore/src/file_abstraction.rs | 19 +++++++++++++++++++ libimagstore/src/hook/accessor.rs | 19 +++++++++++++++++++ libimagstore/src/hook/aspect.rs | 19 +++++++++++++++++++ libimagstore/src/hook/error.rs | 19 +++++++++++++++++++ libimagstore/src/hook/mod.rs | 19 +++++++++++++++++++ libimagstore/src/hook/position.rs | 19 +++++++++++++++++++ libimagstore/src/hook/result.rs | 19 +++++++++++++++++++ libimagstore/src/lib.rs | 19 +++++++++++++++++++ libimagstore/src/store.rs | 19 +++++++++++++++++++ libimagstore/src/storeid.rs | 19 +++++++++++++++++++ 12 files changed, 228 insertions(+) diff --git a/libimagstore/src/configuration.rs b/libimagstore/src/configuration.rs index ff94a1a3..cb1f1447 100644 --- a/libimagstore/src/configuration.rs +++ b/libimagstore/src/configuration.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use toml::Value; /// Check whether the configuration is valid for the store diff --git a/libimagstore/src/error.rs b/libimagstore/src/error.rs index fe0455c1..2c4a8c0d 100644 --- a/libimagstore/src/error.rs +++ b/libimagstore/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_imports!(); use std::convert::From; diff --git a/libimagstore/src/file_abstraction.rs b/libimagstore/src/file_abstraction.rs index a8eb2feb..5053d268 100644 --- a/libimagstore/src/file_abstraction.rs +++ b/libimagstore/src/file_abstraction.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub use self::fs::FileAbstraction; // TODO: diff --git a/libimagstore/src/hook/accessor.rs b/libimagstore/src/hook/accessor.rs index b36d1ff4..8bcca25b 100644 --- a/libimagstore/src/hook/accessor.rs +++ b/libimagstore/src/hook/accessor.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::fmt::Debug; use hook::result::HookResult; diff --git a/libimagstore/src/hook/aspect.rs b/libimagstore/src/hook/aspect.rs index 9c888554..40dc6085 100644 --- a/libimagstore/src/hook/aspect.rs +++ b/libimagstore/src/hook/aspect.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use libimagerror::trace::trace_error; use libimagutil::iter::FoldResult; diff --git a/libimagstore/src/hook/error.rs b/libimagstore/src/hook/error.rs index a576b931..0d890bf3 100644 --- a/libimagstore/src/hook/error.rs +++ b/libimagstore/src/hook/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::default::Default; generate_error_imports!(); diff --git a/libimagstore/src/hook/mod.rs b/libimagstore/src/hook/mod.rs index 43b81de3..5c8e50f2 100644 --- a/libimagstore/src/hook/mod.rs +++ b/libimagstore/src/hook/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::fmt::Debug; use toml::Value; diff --git a/libimagstore/src/hook/position.rs b/libimagstore/src/hook/position.rs index 0ccb563e..8b9f9264 100644 --- a/libimagstore/src/hook/position.rs +++ b/libimagstore/src/hook/position.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #[derive(Debug, Clone)] pub enum HookPosition { StoreUnload, diff --git a/libimagstore/src/hook/result.rs b/libimagstore/src/hook/result.rs index 11766624..e25c7220 100644 --- a/libimagstore/src/hook/result.rs +++ b/libimagstore/src/hook/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use hook::error::HookError; pub type HookResult = Result; diff --git a/libimagstore/src/lib.rs b/libimagstore/src/lib.rs index 9268594e..08eb0afa 100644 --- a/libimagstore/src/lib.rs +++ b/libimagstore/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagstore/src/store.rs b/libimagstore/src/store.rs index f2d0af99..aaf8af7a 100644 --- a/libimagstore/src/store.rs +++ b/libimagstore/src/store.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::collections::HashMap; use std::ops::Drop; use std::path::PathBuf; diff --git a/libimagstore/src/storeid.rs b/libimagstore/src/storeid.rs index b2cfc121..5f979126 100644 --- a/libimagstore/src/storeid.rs +++ b/libimagstore/src/storeid.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::ops::Deref; use std::path::Path; use std::path::PathBuf; From b8ea45facfa0ed833e15e62237dde34975e98b17 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 230/239] libimagstorestdhook: Add copyright notice to all files --- libimagstorestdhook/src/debug.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/flock.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/lib.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/linkverify.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/vcs/git/action.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/vcs/git/config.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/vcs/git/delete.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/vcs/git/error.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/vcs/git/mod.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/vcs/git/result.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/vcs/git/runtime.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/vcs/git/update.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/vcs/git/util.rs | 19 +++++++++++++++++++ libimagstorestdhook/src/vcs/mod.rs | 19 +++++++++++++++++++ 14 files changed, 266 insertions(+) diff --git a/libimagstorestdhook/src/debug.rs b/libimagstorestdhook/src/debug.rs index ef63b015..af20f330 100644 --- a/libimagstorestdhook/src/debug.rs +++ b/libimagstorestdhook/src/debug.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use toml::Value; use libimagstore::hook::Hook; diff --git a/libimagstorestdhook/src/flock.rs b/libimagstorestdhook/src/flock.rs index 07c90a74..6cc30864 100644 --- a/libimagstorestdhook/src/flock.rs +++ b/libimagstorestdhook/src/flock.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use toml::Value; use fs2::FileExt; diff --git a/libimagstorestdhook/src/lib.rs b/libimagstorestdhook/src/lib.rs index bca7eb2c..fe5e4ebc 100644 --- a/libimagstorestdhook/src/lib.rs +++ b/libimagstorestdhook/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( dead_code, non_camel_case_types, diff --git a/libimagstorestdhook/src/linkverify.rs b/libimagstorestdhook/src/linkverify.rs index cf877526..3b3c3cea 100644 --- a/libimagstorestdhook/src/linkverify.rs +++ b/libimagstorestdhook/src/linkverify.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use toml::Value; diff --git a/libimagstorestdhook/src/vcs/git/action.rs b/libimagstorestdhook/src/vcs/git/action.rs index d179dbda..76ea91b8 100644 --- a/libimagstorestdhook/src/vcs/git/action.rs +++ b/libimagstorestdhook/src/vcs/git/action.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::fmt::{Display, Formatter, Error}; /// Utility type to specify which kind of store action is running diff --git a/libimagstorestdhook/src/vcs/git/config.rs b/libimagstorestdhook/src/vcs/git/config.rs index f692edbb..c68743d3 100644 --- a/libimagstorestdhook/src/vcs/git/config.rs +++ b/libimagstorestdhook/src/vcs/git/config.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use toml::Value; use libimagerror::into::IntoError; diff --git a/libimagstorestdhook/src/vcs/git/delete.rs b/libimagstorestdhook/src/vcs/git/delete.rs index b5c0e56b..a2756a55 100644 --- a/libimagstorestdhook/src/vcs/git/delete.rs +++ b/libimagstorestdhook/src/vcs/git/delete.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use std::path::Path; use std::fmt::{Debug, Formatter, Error as FmtError}; diff --git a/libimagstorestdhook/src/vcs/git/error.rs b/libimagstorestdhook/src/vcs/git/error.rs index 9f006a03..0481ebef 100644 --- a/libimagstorestdhook/src/vcs/git/error.rs +++ b/libimagstorestdhook/src/vcs/git/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use git2::Error as Git2Error; use libimagstore::hook::error::HookError as HE; diff --git a/libimagstorestdhook/src/vcs/git/mod.rs b/libimagstorestdhook/src/vcs/git/mod.rs index e679e6df..1f126247 100644 --- a/libimagstorestdhook/src/vcs/git/mod.rs +++ b/libimagstorestdhook/src/vcs/git/mod.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + mod action; mod config; pub mod delete; diff --git a/libimagstorestdhook/src/vcs/git/result.rs b/libimagstorestdhook/src/vcs/git/result.rs index 249fd4da..bf161eb5 100644 --- a/libimagstorestdhook/src/vcs/git/result.rs +++ b/libimagstorestdhook/src/vcs/git/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::result::Result as RResult; use vcs::git::error::GitHookError; diff --git a/libimagstorestdhook/src/vcs/git/runtime.rs b/libimagstorestdhook/src/vcs/git/runtime.rs index 76895935..27fde40c 100644 --- a/libimagstorestdhook/src/vcs/git/runtime.rs +++ b/libimagstorestdhook/src/vcs/git/runtime.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use git2::Repository; diff --git a/libimagstorestdhook/src/vcs/git/update.rs b/libimagstorestdhook/src/vcs/git/update.rs index fc8d451b..d84ffcff 100644 --- a/libimagstorestdhook/src/vcs/git/update.rs +++ b/libimagstorestdhook/src/vcs/git/update.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::path::PathBuf; use std::path::Path; use std::fmt::{Debug, Formatter, Error as FmtError}; diff --git a/libimagstorestdhook/src/vcs/git/util.rs b/libimagstorestdhook/src/vcs/git/util.rs index 1e1dd03d..bfeb2c2f 100644 --- a/libimagstorestdhook/src/vcs/git/util.rs +++ b/libimagstorestdhook/src/vcs/git/util.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + //! Utility functionality for integrating git hooks in the store //! //! Contains primitives to create a repository within the store path diff --git a/libimagstorestdhook/src/vcs/mod.rs b/libimagstorestdhook/src/vcs/mod.rs index c2bf1c3e..7449c7bc 100644 --- a/libimagstorestdhook/src/vcs/mod.rs +++ b/libimagstorestdhook/src/vcs/mod.rs @@ -1 +1,20 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub mod git; From 6d3eeaea8d972c286bf98b8caa815689ec227ed6 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 231/239] libimagtimeui: Add copyright notice to all files --- libimagtimeui/src/cli.rs | 19 +++++++++++++++++++ libimagtimeui/src/date.rs | 19 +++++++++++++++++++ libimagtimeui/src/datetime.rs | 19 +++++++++++++++++++ libimagtimeui/src/lib.rs | 19 +++++++++++++++++++ libimagtimeui/src/parse.rs | 19 +++++++++++++++++++ libimagtimeui/src/time.rs | 19 +++++++++++++++++++ libimagtimeui/src/ui.rs | 19 +++++++++++++++++++ 7 files changed, 133 insertions(+) diff --git a/libimagtimeui/src/cli.rs b/libimagtimeui/src/cli.rs index 001c2a45..7db6c33d 100644 --- a/libimagtimeui/src/cli.rs +++ b/libimagtimeui/src/cli.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use clap::Arg; pub fn build_datetime_cli_component<'a, 'b>() -> Arg<'a, 'b> { diff --git a/libimagtimeui/src/date.rs b/libimagtimeui/src/date.rs index 987ad764..e44cc389 100644 --- a/libimagtimeui/src/date.rs +++ b/libimagtimeui/src/date.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use chrono::naive::date::NaiveDate as ChronoNaiveDate; use parse::Parse; diff --git a/libimagtimeui/src/datetime.rs b/libimagtimeui/src/datetime.rs index b78a7436..be718794 100644 --- a/libimagtimeui/src/datetime.rs +++ b/libimagtimeui/src/datetime.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use chrono::naive::datetime::NaiveDateTime as ChronoNaiveDateTime; use parse::Parse; diff --git a/libimagtimeui/src/lib.rs b/libimagtimeui/src/lib.rs index fa47a930..df9c4e47 100644 --- a/libimagtimeui/src/lib.rs +++ b/libimagtimeui/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagtimeui/src/parse.rs b/libimagtimeui/src/parse.rs index 8898e184..b578551b 100644 --- a/libimagtimeui/src/parse.rs +++ b/libimagtimeui/src/parse.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub trait Parse : Sized { fn parse(s: &str) -> Option; diff --git a/libimagtimeui/src/time.rs b/libimagtimeui/src/time.rs index dc5cbc1a..3506a0be 100644 --- a/libimagtimeui/src/time.rs +++ b/libimagtimeui/src/time.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use chrono::naive::time::NaiveTime as ChronoNaiveTime; use parse::Parse; diff --git a/libimagtimeui/src/ui.rs b/libimagtimeui/src/ui.rs index 691e8c47..642d5203 100644 --- a/libimagtimeui/src/ui.rs +++ b/libimagtimeui/src/ui.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + pub fn time_ui_fmtstr() -> &'static str { "YYYY-MM-DD[THH[:mm[:ss]]]" } From f3373cde7e61264682910c06bb401785ec890a4d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 232/239] libimagtodo: Add copyright notice to all files --- libimagtodo/src/error.rs | 19 +++++++++++++++++++ libimagtodo/src/lib.rs | 19 +++++++++++++++++++ libimagtodo/src/result.rs | 19 +++++++++++++++++++ libimagtodo/src/task.rs | 19 +++++++++++++++++++ 4 files changed, 76 insertions(+) diff --git a/libimagtodo/src/error.rs b/libimagtodo/src/error.rs index ebcebf3e..c19a6e52 100644 --- a/libimagtodo/src/error.rs +++ b/libimagtodo/src/error.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + generate_error_module!( generate_error_types!(TodoError, TodoErrorKind, ConversionError => "Conversion Error", diff --git a/libimagtodo/src/lib.rs b/libimagtodo/src/lib.rs index 171856f8..5a7584ec 100644 --- a/libimagtodo/src/lib.rs +++ b/libimagtodo/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagtodo/src/result.rs b/libimagtodo/src/result.rs index d14bf499..7962851c 100644 --- a/libimagtodo/src/result.rs +++ b/libimagtodo/src/result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use error::TodoError; use std::result::Result as RResult; diff --git a/libimagtodo/src/task.rs b/libimagtodo/src/task.rs index 16ba3167..d51d0407 100644 --- a/libimagtodo/src/task.rs +++ b/libimagtodo/src/task.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::collections::BTreeMap; use std::ops::{Deref, DerefMut}; use std::io::BufRead; From 0a70ea68ea7e73dbb27e0df67d13884d44d414fa Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 1 Oct 2016 17:35:06 +0200 Subject: [PATCH 233/239] libimagutil: Add copyright notice to all files --- libimagutil/src/debug_result.rs | 19 +++++++++++++++++++ libimagutil/src/edit.rs | 19 +++++++++++++++++++ libimagutil/src/info_result.rs | 19 +++++++++++++++++++ libimagutil/src/ismatch.rs | 19 +++++++++++++++++++ libimagutil/src/iter.rs | 19 +++++++++++++++++++ libimagutil/src/key_value_split.rs | 19 +++++++++++++++++++ libimagutil/src/lib.rs | 19 +++++++++++++++++++ libimagutil/src/log_result.rs | 19 +++++++++++++++++++ libimagutil/src/variants.rs | 19 +++++++++++++++++++ libimagutil/src/warn_exit.rs | 19 +++++++++++++++++++ libimagutil/src/warn_result.rs | 19 +++++++++++++++++++ 11 files changed, 209 insertions(+) diff --git a/libimagutil/src/debug_result.rs b/libimagutil/src/debug_result.rs index 405cddd8..e7506633 100644 --- a/libimagutil/src/debug_result.rs +++ b/libimagutil/src/debug_result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + // Generates a extension for the `Result`, named `DebugResult` which has functionality to // print either `T` or `E` via `debug!()`. generate_result_logging_extension!( diff --git a/libimagutil/src/edit.rs b/libimagutil/src/edit.rs index ad23b6ed..3cf459f4 100644 --- a/libimagutil/src/edit.rs +++ b/libimagutil/src/edit.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use std::io::Read; use std::io::Seek; use std::io::SeekFrom; diff --git a/libimagutil/src/info_result.rs b/libimagutil/src/info_result.rs index 235f4f53..9c106bc8 100644 --- a/libimagutil/src/info_result.rs +++ b/libimagutil/src/info_result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + // Generates a extension for the `Result`, named `DebugResult` which has functionality to // print either `T` or `E` via `info!()`. generate_result_logging_extension!( diff --git a/libimagutil/src/ismatch.rs b/libimagutil/src/ismatch.rs index 9739f139..e47ee6bf 100644 --- a/libimagutil/src/ismatch.rs +++ b/libimagutil/src/ismatch.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #[macro_export] macro_rules! is_match { ($expression: expr, $($pattern:tt)+) => { diff --git a/libimagutil/src/iter.rs b/libimagutil/src/iter.rs index 52d723bf..2f2bb5b7 100644 --- a/libimagutil/src/iter.rs +++ b/libimagutil/src/iter.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + /// Folds its contents to a result. pub trait FoldResult: Sized { type Item; diff --git a/libimagutil/src/key_value_split.rs b/libimagutil/src/key_value_split.rs index f1a7a7c7..ff2870bf 100644 --- a/libimagutil/src/key_value_split.rs +++ b/libimagutil/src/key_value_split.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + use regex::Regex; use std::convert::Into; diff --git a/libimagutil/src/lib.rs b/libimagutil/src/lib.rs index c0026c6f..adf0ac78 100644 --- a/libimagutil/src/lib.rs +++ b/libimagutil/src/lib.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + #![deny( non_camel_case_types, non_snake_case, diff --git a/libimagutil/src/log_result.rs b/libimagutil/src/log_result.rs index 95da299b..45977b2a 100644 --- a/libimagutil/src/log_result.rs +++ b/libimagutil/src/log_result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + /// This macro is used to generate extensions for the `Result` type which only have /// sideeffects. /// diff --git a/libimagutil/src/variants.rs b/libimagutil/src/variants.rs index a57e694d..2f0746d2 100644 --- a/libimagutil/src/variants.rs +++ b/libimagutil/src/variants.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + /** * Generate variants of a base value by applying parts * diff --git a/libimagutil/src/warn_exit.rs b/libimagutil/src/warn_exit.rs index 399ebcd8..fbda4d25 100644 --- a/libimagutil/src/warn_exit.rs +++ b/libimagutil/src/warn_exit.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + /// This function prints the string `s` via the `warn!()` macro and then exits with the code `code` /// as status. /// diff --git a/libimagutil/src/warn_result.rs b/libimagutil/src/warn_result.rs index b30e71f8..6b05b285 100644 --- a/libimagutil/src/warn_result.rs +++ b/libimagutil/src/warn_result.rs @@ -1,3 +1,22 @@ +// +// imag - the personal information management suite for the commandline +// Copyright (C) 2015, 2016 Matthias Beyer and contributors +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; version +// 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +// + // Generates a extension for the `Result`, named `DebugResult` which has functionality to // print either `T` or `E` via `warn!()`. generate_result_logging_extension!( From 73b11e4bd285e74b0a17db207627a0543d54c6fd Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Mon, 3 Oct 2016 20:44:06 +0200 Subject: [PATCH 234/239] Rewrite README.md --- README.md | 257 +++++++++++++++++++++++------------------------------- 1 file changed, 107 insertions(+), 150 deletions(-) diff --git a/README.md b/README.md index 72c2fc11..a5350045 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,118 @@ # imag - [imag-pim.org](http://imag-pim.org) -Imag is a CLI PIM suite you can -integrate in your tools of choice (Editor, MUA, RSS reader, etc etc). +`imag` is a commandline personal information management suite. + +**This application is in early development. There are _some_ things that work, +but we do not consider anything stable or usable at this moment. Feel free to +play around anyways.** [![Build Status](https://travis-ci.org/matthiasbeyer/imag.svg?branch=master)](https://travis-ci.org/matthiasbeyer/imag) [![Issue Stats](http://www.issuestats.com/github/matthiasbeyer/imag/badge/pr?style=flat-square)](http://www.issuestats.com/github/matthiasbeyer/imag) [![Issue Stats](http://www.issuestats.com/github/matthiasbeyer/imag/badge/issue?style=flat-square)](http://www.issuestats.com/github/matthiasbeyer/imag) [![license](https://img.shields.io/github/license/matthiasbeyer/imag.svg?maxAge=2592000?style=flat-square)]() +## What is this / Goal and Functionality + +Our (long-term) goal is to + +> Create a fast, reliable commandline personal +> information management suite which covers all aspects of personal information +> management, consists of reusable parts and integrates well with known +> commandline tools. + +We try to implement as many aspects of personal information management (PIM), +but re-use existing commandline tools. +We do this by tracking/referring to the data the tools create. +A user can now link pieces of data (from different tools), tag this data and +query/search this data using imag. +So `imag` is more like a data-mining helper than an actual PIM tool, but we +implement some of the PIM aspects directly in `imag`. +Parts of PIM (we call them "modules") that are already implemented and basically +working: + +* todo (via taskwarrior, we track the tasks one creates in taskwarrior) +* diary +* notes +* bookmarks +* counter (just an example, nothing that usable) + +Helper modules that come with `imag` but are not "PIM aspects": + +* linking entries +* viewing entries +* tagging entries +* creating misc entries +* creating entries that refer to files/directories + +## Building/Running + +Here goes how to try `imag` out. + +`imag` is a _suite_ of tools and you can build them individually. +All subdirectories prefixed with "`libimag"` are libraries for the respective +binaries. +All subdirectories prefixed with `"imag-"` are binaries and compiling them will +give you a commandline application. + +### Building + +By now, there are several targets in the Makefile, fulfilling following roles: + +* `all` is the default and builds every crate in debug mode. + To build a single module, call `make `, for example `make imag-store`. +* `release`, as the name implies, builds every module in release mode. + E.G.: `make imag-store-release` to build "imag-store" in release mode. +* `install` will install all commandline modules to the default installation + root (see `man cargo-install`). + To install a single module, run `make -install`, + E.G.: `make imag-store-install` +* `bin`/`lib` are separate targets for either building all binaries or + libraries. +* `lib-test` runs `cargo test` for all libraries. + For testing a single library, E.G.: `make test-libimagstore`. +* `clean` will run `cargo clean` in every crate. + For cleaning a single crate, use `make imag-store-clean` for example. +* to build _only_ the `imag` binary, use the target `imag-bin` + (`imag-bin-release` for release build, `imag-bin-clean` for `cargo clean`ing). + +### Running + +To test out a single module, simply using `cargo run -- ` in the +respective directory will do the trick. +But you can also `make ` and call the binary on the commandline. +For using it "normally", install the +binaries as described above, as well as the imag-binary: + +``` +$> make install +``` + +The installation root of the binaries may not yet be in your $PATH. +To see, where this installation root is, check out `man cargo-install`. +To change the $PATH in bash: + +```bash +$> PATH=$PATH:~/.cargo/bin +$> imag --help +``` + +To test, simply add `--help` to one of the above commands: + +```bash +$> imag counter --help +``` + +## Documentation + +For detailed information, please read [the documentation](./doc/). +You can either read the Markdown files or compile it to HTML/PDF using +[pandoc](http://pandoc.org). +Developer documentation is also available +[online on github.io](https://matthiasbeyer.github.io/imag/imag_documentation/index.html). + +Please note that the documentation is work in progress as well and may be +outdated. + ## Please contribute! We are looking work contributors! @@ -21,154 +126,6 @@ things! Also have a look at [the CONTRIBUTING.md file](./CONTRIBUTING.md)! -## Goal - -Our goal is to - -> Create a fast, reliable, forwards/backwards compatible commandline personal -> information management suite which covers all aspects of personal information -> management, consists of reusable parts and integrates well with known -> commandline tools. - -We try to accomplish these requirements: - -* "fast": We use the awesome, fast and safe programming language "Rust" -* "reliable": We try to test every aspect of our software. Our build process - ensures that the build breaks whenever a library interface changes and the - modules which use the library are not updated. -* "forwards/backwards compatible:" Our (plain text) on-disk data format and - storage library both ensure that incompatibilities are captured and resolved - ([using](https://crates.io/crates/semver) [semver](https://semver.org)) -* "commandline": We ensure that everything can be done by commandline calls, for - some modules there might be a curses-like UI, but there are no graphical - clients and there never will be any within this codebase. We use - [clap](https://crates.io/crates/clap) for commandline-interface building and - we try to keep the interface easy and consistent between modules. -* "personal": We store everything as plain text in a store inside the users - `$HOME` directory. There will be a version-control (most surely `git`) hook - integrated to sync between several machines. There are no multi-user features - included or planned at the time of writing. -* "information management": We want to give the user the possibility to put - every single information about their personal lives into the store and we try - hard to provide a sane interface to query and retrieve data from this - database. -* "covers all the aspects of personal information management": We want to - provide modules for: - * contact management - * calendar - * diary - * notes - * personal wiki - * news (rss) - * passwords - * images - * music - * movies - * personal project management - * podcast management - * ledger - * mail - * bibliography management - * ... and many, many more. -* "constists of reusable parts": Every functionality is implemented as library. - The binaries we ship are just commandline-interace-to-library-interface - translators -* "integrates well with known commandline tools": We do not re-invent the wheel. - **We do not implement "yet another password manager", but use - [the standard unix password manager](https://www.passwordstore.org/), do not - implement a news reader, but use [newsbeuter](http://www.newsbeuter.org/), - do not reimplement a mail reader, etc etc.** - We do not copy images, movies or other data to the store but "link" them into - the store, so you can use imag tools to query and access this data, but still - live with your beloved commandline apps. We do not want to duplicate work but - reuse as much as possible. - You don't like one of the applications we use (for example `pass` as password - manager)? Sure, feel free to submit patches so the user is able to switch the - used tool, as long as it doesn't break the workflow. We will happily merge - them! - -## Current state of development - -**This application is in _really_ early development.** - -We have implemented the very core of the system, though some more utility work -is to be done. -We have the store working, a hooks API and some default hooks are in -development. -Basic features like tagging and linking entries is possible as well as viewing -entries. -Some small things are implemented, like a note-taking module, a basic diary -module, a counter module and a bookmark module. -These modules contain basic features and are subject to change. -More modules are about to be implemented. - -Though, the very core of the system is stable and nothing prevents _you_ from -contributing and implementing a module. - -## Building/Running - -Here goes how to try imag out. - -### Building - -By now, there are several targets in the Makefile, fulfilling following roles: -* `all` Is the default and builds every crate in debug mode. This is the same as - traversing every directory yourself and calling `cargo build` in it. - To build a single crate, call `make `, for example - `make imag-store` -* `release`, as the name implies, builds every crate in release mode. Following - the example above, to build `imag-store` in release mode, call - `make imag-store-release`. -* `install` will install all binary crates to the default installation root (see - `man cargo-install`). To install a single module, run `make -install`, - again, for example: `make imag-store-install` -* `bin`/`lib` are separate targets for either building all binaries or - libraries. -* `lib-test` runs `cargo test` for all libraries. For testing a single library, - run `make test-libimagstore` for example. -* `clean` will run `cargo clean` in every crate. Again, for cleaning a single - crate, use `make imag-store-clean` for example. -* to build _only_ the `imag` binary, use the target `imag-bin` - (`imag-bin-release` for release build, `imag-bin-update` for - `cargo update`ing, `imag-bin-clean` for `cargo clean`ing). - -### Running - -To test out a single module, simply using `cargo run -- ` in the -respective directory will do the trick. For using it "normally", install the -binaries as described above, as well as the imag-binary: -``` -$> make install -``` -The installation root of the binaries (a.k.a. where they are installed to), may -not yet be in your $PATH. To see, where this installation root is, check out -`man cargo-install`. To change the $PATH in bash: - -```bash -$> PATH=$PATH:~/.cargo/bin -$> imag --help -``` - -To test, simply add `--help` to one of the above commands: - -```bash -$> imag counter --help -``` - -Please note that $PATH will be reset in a new shell. To make these changes -permanent, see the User Guide of your shell. - -## Documentation - -For detailed information, please read [the documentation](./doc/) (You can -either read the Markdown files or compile it to HTML/PDF using -[pandoc](http://pandoc.org)). -Developer documentation is also available -[online on github.io](https://matthiasbeyer.github.io/imag/imag_documentation/index.html). - -Please note that the documentation is work in progress as well and may be -outdated. - ## Contact Have a look at [our website](http://imag-pim.org) where you can find some From 6b9da878f1a8c59c471f965a4066f83ba5e1cc90 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 4 Oct 2016 13:49:41 +0200 Subject: [PATCH 235/239] Fix commata --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a5350045..2bb92886 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ $> make install ``` The installation root of the binaries may not yet be in your $PATH. -To see, where this installation root is, check out `man cargo-install`. +To see where this installation root is check out `man cargo-install`. To change the $PATH in bash: ```bash From 6abdd88182156ab13f1529a226632456df7f54ce Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 4 Oct 2016 13:49:57 +0200 Subject: [PATCH 236/239] Fix wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2bb92886..8c1cbda5 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ outdated. ## Please contribute! -We are looking work contributors! +We are looking for contributors! There is always a number of [complexity/easy tagged issues](https://github.com/matthiasbeyer/imag/issues?q=is%3Aopen+is%3Aissue+label%3Acomplexity%2Feasy) From d88c5d9a016ee529a09f3adeadf18853655caaff Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 7 Oct 2016 17:16:45 +0200 Subject: [PATCH 237/239] Add section about how to stay uptodate --- README.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/README.md b/README.md index 8c1cbda5..ee8e5c8b 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,22 @@ To test, simply add `--help` to one of the above commands: $> imag counter --help ``` +## Staying up-to-date + +Despite we have a [official site for imag](http://imag-pim.org), I do not push +updates to this site, yet. Anyways, I post a blog articles about what happened +in the last two weeks every other week. + +You can find them +[on my personal blog, tagged "imag"](http://beyermatthias.de/tags/imag.html) + +I also post these blog posts +[on reddit](https://www.reddit.com/r/rust/search?q=What%27s+coming+up+in+imag&restrict_sr=on) +and submit them to [this-week-in-rust](https://this-week-in-rust.org/). + +From time to time I publish an article about imag which does not focus on some +things that are happening, but rather about something more general. + ## Documentation For detailed information, please read [the documentation](./doc/). From d506e869ca62e740c6895d72decf70db719b634d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 7 Oct 2016 17:35:43 +0200 Subject: [PATCH 238/239] Add dependency: libimagutil --- imag-ref/Cargo.toml | 3 +++ imag-ref/src/main.rs | 1 + 2 files changed, 4 insertions(+) diff --git a/imag-ref/Cargo.toml b/imag-ref/Cargo.toml index da41fdcf..221615a2 100644 --- a/imag-ref/Cargo.toml +++ b/imag-ref/Cargo.toml @@ -27,3 +27,6 @@ path = "../libimaginteraction" [dependencies.libimagentrylist] path = "../libimagentrylist" +[dependencies.libimagutil] +path = "../libimagutil" + diff --git a/imag-ref/src/main.rs b/imag-ref/src/main.rs index fd29a4a6..54465494 100644 --- a/imag-ref/src/main.rs +++ b/imag-ref/src/main.rs @@ -9,6 +9,7 @@ extern crate libimagref; extern crate libimagerror; extern crate libimagentrylist; extern crate libimaginteraction; +extern crate libimagutil; mod ui; use ui::build_ui; From a9deb488b3057e5ee4dbd7b9d5594f944d591a5d Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 8 Oct 2016 00:34:38 +0200 Subject: [PATCH 239/239] Fix missing [[ on travis --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 344dc11a..ad164ccc 100644 --- a/Makefile +++ b/Makefile @@ -74,7 +74,7 @@ $(TARGETS): %: .FORCE $(BIN_TARGET_TESTS): %-test: % .FORCE @$(ECHO) "\t[BINTEST]:\t$@" - if [[ -f $(subst -test,,$@)/tests/Makefile ]]; then \ + if [ -f $(subst -test,,$@)/tests/Makefile ]; then \ $(MAKE) -C $(subst -test,,$@)/tests || exit 1;\ fi;