From c6f1c78597a371d91c3879396ac0f6363fbc7589 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Fri, 16 Mar 2018 23:53:41 +0100 Subject: [PATCH 01/12] Fix typo in changelog --- doc/src/09020-changelog.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md index 072d9009..b0f99ec8 100644 --- a/doc/src/09020-changelog.md +++ b/doc/src/09020-changelog.md @@ -39,8 +39,8 @@ This section contains the changelog from the last release to the next release. address and either shows or lists the found contacts * `imag-contact list` and `imag-contact find` is now able to print the output as JSON. - * `imag-edit` can now read store ids from stdin, sorts - `imag ids | fzf | imag edit -I` is not a thing. + * `imag-edit` can now read store ids from stdin, so + `imag ids | fzf | imag edit -I` is now a thing. * `imag ids` does not print the path of the store. Can be turned on using commandline flag. * Minor changes From 7e623f39b88b51e6fa3c8649c387edf162dc0f72 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sat, 17 Mar 2018 00:06:13 +0100 Subject: [PATCH 02/12] Add message why panic So we see that when grepping the source for `unimplemented!()`. --- lib/core/libimagstore/src/iter.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/core/libimagstore/src/iter.rs b/lib/core/libimagstore/src/iter.rs index 8df32a64..b5d82348 100644 --- a/lib/core/libimagstore/src/iter.rs +++ b/lib/core/libimagstore/src/iter.rs @@ -198,7 +198,7 @@ mod compile_test { use storeid::StoreId; fn store() -> Store { - unimplemented!() + unimplemented!("Not implemented because in compile-test") } fn test_compile_get() { From 127681498f96add62b7328e19f61665c59efa75c Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 18 Mar 2018 14:27:45 +0100 Subject: [PATCH 03/12] Add debug output in tests --- bin/core/imag-link/Cargo.toml | 3 ++ bin/core/imag-link/src/main.rs | 95 ++++++++++++++++++++++++++++++---- 2 files changed, 89 insertions(+), 9 deletions(-) diff --git a/bin/core/imag-link/Cargo.toml b/bin/core/imag-link/Cargo.toml index c05fe184..607f5a08 100644 --- a/bin/core/imag-link/Cargo.toml +++ b/bin/core/imag-link/Cargo.toml @@ -38,6 +38,9 @@ version = ">=2.29" default-features = false features = ["color", "suggestions"] +[dev-dependencies] +env_logger = "0.5" + [dev-dependencies.libimagutil] version = "0.7.0" path = "../../../lib/etc/libimagutil" diff --git a/bin/core/imag-link/src/main.rs b/bin/core/imag-link/src/main.rs index 4fd74264..7f67b53e 100644 --- a/bin/core/imag-link/src/main.rs +++ b/bin/core/imag-link/src/main.rs @@ -37,6 +37,7 @@ extern crate clap; extern crate url; #[cfg(test)] extern crate toml; #[cfg(test)] extern crate toml_query; +#[cfg(test)] extern crate env_logger; extern crate libimagentrylink; #[macro_use] extern crate libimagrt; @@ -119,8 +120,12 @@ fn main() { fn get_entry_by_name<'a>(rt: &'a Runtime, name: &str) -> Result>, StoreError> { use libimagstore::storeid::StoreId; - StoreId::new(Some(rt.store().path().clone()), PathBuf::from(name)) - .and_then(|id| rt.store().get(id)) + debug!("Getting: {:?}", name); + let result = StoreId::new(Some(rt.store().path().clone()), PathBuf::from(name)) + .and_then(|id| rt.store().get(id)); + + debug!(" => : {:?}", result); + result } fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I) @@ -128,10 +133,14 @@ fn link_from_to<'a, I>(rt: &'a Runtime, from: &'a str, to: I) { let mut from_entry = match get_entry_by_name(rt, from).map_err_trace_exit_unwrap(1) { Some(e) => e, - None => warn_exit("No 'from' entry", 1), + None => { + debug!("No 'from' entry"); + warn_exit("No 'from' entry", 1) + }, }; for entry in to { + debug!("Handling 'to' entry: {:?}", entry); if PathBuf::from(entry).exists() { debug!("Linking externally: {:?} -> {:?}", from, entry); let url = Url::parse(entry).unwrap_or_else(|e| { @@ -312,6 +321,10 @@ mod tests { use libimagstore::storeid::StoreId; use libimagstore::store::{Result as StoreResult, FileLockEntry, Entry}; + fn setup_logging() { + let _ = ::env_logger::try_init(); + } + make_mock_app! { app "imag-link"; modulename mock; @@ -327,8 +340,14 @@ mod tests { let default_entry = Entry::new(StoreId::new_baseless(PathBuf::from("")).unwrap()).to_str(); + debug!("Default entry constructed"); + let id = StoreId::new_baseless(path)?; + debug!("StoreId constructed: {:?}", id); + let mut entry = rt.store().create(id.clone())?; + + debug!("Entry constructed: {:?}", id); entry.get_content_mut().push_str(&default_entry); Ok(id) @@ -351,77 +370,111 @@ mod tests { #[test] fn test_link_modificates() { - let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2"]) + setup_logging(); + let rt = generate_test_runtime(vec!["internal", "test1", "test2"]) .unwrap(); + debug!("Runtime created"); + let test_id1 = create_test_default_entry(&rt, "test1").unwrap(); let test_id2 = create_test_default_entry(&rt, "test2").unwrap(); + debug!("Entries created"); + link_from_to(&rt, "test1", vec!["test2"].into_iter()); + debug!("Linking done"); + let test_entry1 = rt.store().get(test_id1).unwrap().unwrap(); let test_links1 = get_entry_links(&test_entry1).unwrap(); let test_entry2 = rt.store().get(test_id2).unwrap().unwrap(); let test_links2 = get_entry_links(&test_entry2).unwrap(); + debug!("Asserting"); + assert_ne!(*test_links1, links_toml_value(vec![])); assert_ne!(*test_links2, links_toml_value(vec![])); } #[test] fn test_linking_links() { - let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2"]) + setup_logging(); + let rt = generate_test_runtime(vec!["internal", "test1", "test2"]) .unwrap(); + debug!("Runtime created"); + let test_id1 = create_test_default_entry(&rt, "test1").unwrap(); let test_id2 = create_test_default_entry(&rt, "test2").unwrap(); + debug!("Test entries created"); + link_from_to(&rt, "test1", vec!["test2"].into_iter()); + debug!("Linking done"); + let test_entry1 = rt.store().get(test_id1).unwrap().unwrap(); let test_links1 = get_entry_links(&test_entry1).unwrap(); let test_entry2 = rt.store().get(test_id2).unwrap().unwrap(); let test_links2 = get_entry_links(&test_entry2).unwrap(); + debug!("Asserting"); + assert_eq!(*test_links1, links_toml_value(vec!["test2"])); assert_eq!(*test_links2, links_toml_value(vec!["test1"])); } #[test] fn test_multilinking() { - let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2"]) + setup_logging(); + let rt = generate_test_runtime(vec!["internal", "test1", "test2"]) .unwrap(); + debug!("Runtime created"); + let test_id1 = create_test_default_entry(&rt, "test1").unwrap(); let test_id2 = create_test_default_entry(&rt, "test2").unwrap(); + debug!("Test entries created"); + link_from_to(&rt, "test1", vec!["test2"].into_iter()); link_from_to(&rt, "test1", vec!["test2"].into_iter()); + debug!("Linking done"); + let test_entry1 = rt.store().get(test_id1).unwrap().unwrap(); let test_links1 = get_entry_links(&test_entry1).unwrap(); let test_entry2 = rt.store().get(test_id2).unwrap().unwrap(); let test_links2 = get_entry_links(&test_entry2).unwrap(); + debug!("Asserting"); + assert_eq!(*test_links1, links_toml_value(vec!["test2"])); assert_eq!(*test_links2, links_toml_value(vec!["test1"])); } #[test] fn test_linking_more_than_two() { - let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2", "test3"]) + setup_logging(); + let rt = generate_test_runtime(vec!["internal", "test1", "test2", "test3"]) .unwrap(); + debug!("Runtime created"); + let test_id1 = create_test_default_entry(&rt, "test1").unwrap(); let test_id2 = create_test_default_entry(&rt, "test2").unwrap(); let test_id3 = create_test_default_entry(&rt, "test3").unwrap(); + debug!("Test entries created"); + link_from_to(&rt, "test1", vec!["test2", "test3"].into_iter()); link_from_to(&rt, "test1", vec!["test2", "test3"].into_iter()); + debug!("Linking done"); + let test_entry1 = rt.store().get(test_id1).unwrap().unwrap(); let test_links1 = get_entry_links(&test_entry1).unwrap(); @@ -431,6 +484,8 @@ mod tests { let test_entry3 = rt.store().get(test_id3).unwrap().unwrap(); let test_links3 = get_entry_links(&test_entry3).unwrap(); + debug!("Asserting"); + assert_eq!(*test_links1, links_toml_value(vec!["test2", "test3"])); assert_eq!(*test_links2, links_toml_value(vec!["test1"])); assert_eq!(*test_links3, links_toml_value(vec!["test1"])); @@ -440,45 +495,65 @@ mod tests { #[test] fn test_linking_links_unlinking_removes_links() { - let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2"]) + setup_logging(); + let rt = generate_test_runtime(vec!["internal", "test1", "test2"]) .unwrap(); + debug!("Runtime created"); + let test_id1 = create_test_default_entry(&rt, "test1").unwrap(); let test_id2 = create_test_default_entry(&rt, "test2").unwrap(); + debug!("Test entries created"); + link_from_to(&rt, "test1", vec!["test2"].into_iter()); + debug!("Linking done"); + let rt = reset_test_runtime(vec!["remove", "test1", "test2"], rt) .unwrap(); remove_linking(&rt); + debug!("Linking removed"); + let test_entry1 = rt.store().get(test_id1).unwrap().unwrap(); let test_links1 = get_entry_links(&test_entry1).unwrap(); let test_entry2 = rt.store().get(test_id2).unwrap().unwrap(); let test_links2 = get_entry_links(&test_entry2).unwrap(); + debug!("Asserting"); + assert_eq!(*test_links1, links_toml_value(vec![])); assert_eq!(*test_links2, links_toml_value(vec![])); } #[test] fn test_linking_and_unlinking_more_than_two() { - let rt = generate_test_runtime(vec!["internal", "add", "test1", "test2", "test3"]) + setup_logging(); + let rt = generate_test_runtime(vec!["internal", "test1", "test2", "test3"]) .unwrap(); + debug!("Runtime created"); + let test_id1 = create_test_default_entry(&rt, "test1").unwrap(); let test_id2 = create_test_default_entry(&rt, "test2").unwrap(); let test_id3 = create_test_default_entry(&rt, "test3").unwrap(); + debug!("Test entries created"); + link_from_to(&rt, "test1", vec!["test2", "test3"].into_iter()); + debug!("linking done"); + let rt = reset_test_runtime(vec!["remove", "test1", "test2", "test3"], rt) .unwrap(); remove_linking(&rt); + debug!("linking removed"); + let test_entry1 = rt.store().get(test_id1).unwrap().unwrap(); let test_links1 = get_entry_links(&test_entry1).unwrap(); @@ -488,6 +563,8 @@ mod tests { let test_entry3 = rt.store().get(test_id3).unwrap().unwrap(); let test_links3 = get_entry_links(&test_entry3).unwrap(); + debug!("Asserting"); + assert_eq!(*test_links1, links_toml_value(vec![])); assert_eq!(*test_links2, links_toml_value(vec![])); assert_eq!(*test_links3, links_toml_value(vec![])); From bcdbb8197af5c32e290b6677e632517a162d1710 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Mar 2018 14:19:38 +0100 Subject: [PATCH 04/12] Use "ui" module in libimagtimeui --- lib/etc/libimagtimeui/src/lib.rs | 1 + lib/etc/libimagtimeui/src/ui.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/etc/libimagtimeui/src/lib.rs b/lib/etc/libimagtimeui/src/lib.rs index d1c5f11f..a70611a5 100644 --- a/lib/etc/libimagtimeui/src/lib.rs +++ b/lib/etc/libimagtimeui/src/lib.rs @@ -44,4 +44,5 @@ pub mod date; pub mod datetime; pub mod parse; pub mod time; +pub mod ui; diff --git a/lib/etc/libimagtimeui/src/ui.rs b/lib/etc/libimagtimeui/src/ui.rs index db1e13d2..37d9b288 100644 --- a/lib/etc/libimagtimeui/src/ui.rs +++ b/lib/etc/libimagtimeui/src/ui.rs @@ -22,7 +22,7 @@ pub fn time_ui_fmtstr() -> &'static str { } pub fn time_ui_fmtstr_expl() -> &'static str { - #r"In the UI, the format for Time is always YEAR-MONTH-DAY. + r#"In the UI, the format for Time is always YEAR-MONTH-DAY. Optionally, Time can be specified by seperating it from the date with 'T'. Minutes and Seconds are optional. "# From 6f33e4e3223973d5fcd701eed6dfea0ffd4e6d32 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Mar 2018 16:42:52 +0100 Subject: [PATCH 05/12] Add debug output --- lib/entry/libimagentryref/src/generators/mod.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/entry/libimagentryref/src/generators/mod.rs b/lib/entry/libimagentryref/src/generators/mod.rs index 427ebaaa..204ae081 100644 --- a/lib/entry/libimagentryref/src/generators/mod.rs +++ b/lib/entry/libimagentryref/src/generators/mod.rs @@ -91,6 +91,7 @@ macro_rules! make_unique_ref_path_generator { } fn unique_hash>(path: A) -> Result { + debug!("Making unique hash for path: {:?}", path.as_ref()); $impl(path) } @@ -135,7 +136,8 @@ macro_rules! make_unique_ref_path_generator { $collectionname } - fn unique_hash>(path: A) -> Result { + fn unique_hash>(path: A) -> ::std::result::Result { + debug!("Making unique hash for path: {:?}", path.as_ref()); $impl(path) } @@ -198,6 +200,7 @@ macro_rules! make_sha_mod { /// Function which can be used by a wrapping UniqueRefPathGenerator to hash only N bytes. pub fn hash_n_bytes>(path: A, n: usize) -> Result { + debug!("Opening '{}' for hashing", path.as_ref().display()); OpenOptions::new() .read(true) .write(false) @@ -233,8 +236,13 @@ macro_rules! make_sha_mod { make_sha_mod! { sha1, Sha1, |buffer: String| { let mut hasher = ::crypto::sha1::Sha1::new(); + + trace!("Hashing: '{:?}'", buffer); hasher.input_str(&buffer); - Ok(String::from(hasher.result_str())) + let res = hasher.result_str(); + trace!("Hash => '{:?}'", res); + + Ok(String::from(res)) } } From 6298cea4d7d0d267754be1f1a692ec210680b9c1 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Mar 2018 17:54:55 +0100 Subject: [PATCH 06/12] Add changelog entry for Ref::make_ref() --- doc/src/09020-changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md index b0f99ec8..968440f0 100644 --- a/doc/src/09020-changelog.md +++ b/doc/src/09020-changelog.md @@ -61,6 +61,7 @@ This section contains the changelog from the last release to the next release. * `imag-tag` commandline was rewritten for positional arguments. * `libimagrt` automatically takes "rt.editor" into account when building editor object + * `libimagentryref` got a utility function for making an entry a ref. * Bugfixes * imag does not panic anymore when piping and breaking that pipe, for example like with `imag store ids | head -n 1`. From c31edd5cf4a113579ec25b4b0f96b1a510207270 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Tue, 20 Mar 2018 17:55:38 +0100 Subject: [PATCH 07/12] Add changelog for hash buffer allocation fix in libimagentryref --- doc/src/09020-changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md index 968440f0..c2031078 100644 --- a/doc/src/09020-changelog.md +++ b/doc/src/09020-changelog.md @@ -85,6 +85,8 @@ This section contains the changelog from the last release to the next release. editor command. * `libimagrt` produced the editor command without taking arguments into account. + * `libimagentryref` got a fix where the buffer for the hash calculation was + not allocated properly. ## 0.6.3 From aa32dd1ec20ee19f4fb9a1bf0dc274148bbf305a Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Wed, 21 Mar 2018 19:00:34 +0100 Subject: [PATCH 08/12] Add debugging output if kairos fails to parse input --- lib/domain/libimaghabit/src/habit.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/domain/libimaghabit/src/habit.rs b/lib/domain/libimaghabit/src/habit.rs index ee7cf294..36c9dcc0 100644 --- a/lib/domain/libimaghabit/src/habit.rs +++ b/lib/domain/libimaghabit/src/habit.rs @@ -348,6 +348,7 @@ pub mod builder { } if let Err(e) = ::kairos::parser::parse(&recur) { + debug!("Kairos failed: {:?}", e); return Err(e).map_err(From::from); } let date = date_to_string(&dateobj); From dacd23103931490fc45c0ac8e4b17899c07b2e78 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 22 Mar 2018 13:46:13 +0100 Subject: [PATCH 09/12] Add changelog for Habit::instance_exists_for_date() --- doc/src/09020-changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md index c2031078..51c307aa 100644 --- a/doc/src/09020-changelog.md +++ b/doc/src/09020-changelog.md @@ -62,6 +62,7 @@ This section contains the changelog from the last release to the next release. * `libimagrt` automatically takes "rt.editor" into account when building editor object * `libimagentryref` got a utility function for making an entry a ref. + * `libimaghabit` got `Habit::instance_exists_for_date()` * Bugfixes * imag does not panic anymore when piping and breaking that pipe, for example like with `imag store ids | head -n 1`. From 200864e2c621363deb5959b26141329f7a15ab10 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 22 Mar 2018 13:47:52 +0100 Subject: [PATCH 10/12] Add changelog for "imag-habit" with "--done" flag --- doc/src/09020-changelog.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md index 51c307aa..5838ef4d 100644 --- a/doc/src/09020-changelog.md +++ b/doc/src/09020-changelog.md @@ -43,6 +43,8 @@ This section contains the changelog from the last release to the next release. `imag ids | fzf | imag edit -I` is now a thing. * `imag ids` does not print the path of the store. Can be turned on using commandline flag. + * `imag-habit today --done` and `imag-habit status --done` was added for + showing habits which are already done. * Minor changes * A license-checker was included into the CI setup, which checks whether all ".rs"-files have the license header at the top of the file From 2b4e8880a46f5784212aeef2198c5c85c70bce63 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 22 Mar 2018 14:14:17 +0100 Subject: [PATCH 11/12] Add changelog entry for Store::create() override fix --- doc/src/09020-changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md index 5838ef4d..ab95ef73 100644 --- a/doc/src/09020-changelog.md +++ b/doc/src/09020-changelog.md @@ -90,6 +90,7 @@ This section contains the changelog from the last release to the next release. account. * `libimagentryref` got a fix where the buffer for the hash calculation was not allocated properly. + * `libimagstore::store::Store::create` overwrote existing entries. ## 0.6.3 From 76abfbda81e888f457430669d5331beadf9912d5 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 22 Mar 2018 14:19:47 +0100 Subject: [PATCH 12/12] Add changelog entry for habit template to instance linking fix --- doc/src/09020-changelog.md | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/src/09020-changelog.md b/doc/src/09020-changelog.md index ab95ef73..93d16341 100644 --- a/doc/src/09020-changelog.md +++ b/doc/src/09020-changelog.md @@ -91,6 +91,7 @@ This section contains the changelog from the last release to the next release. * `libimagentryref` got a fix where the buffer for the hash calculation was not allocated properly. * `libimagstore::store::Store::create` overwrote existing entries. + * `libimaghabit::habit::HabitTemplate` did not link new instances. ## 0.6.3