Commit Graph

6335 Commits

Author SHA1 Message Date
Matthias Beyer 7348378a96 Fix test: Check whether in cache, then get, then check again
After moving an entry, the entry should _not_ be in the cache. This is
just a decision that has to be made, whether we cache the moved entry or
not. I decided to not cache because it is results in less code.

After that check, we get the entry from the backend and then we can
check whether the entry is in the cache, which is then should be.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26 09:57:05 +02:00
Matthias Beyer 583f972788 Add test: Test moving entry with writing to it before and after moving
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26 09:57:05 +02:00
Matthias Beyer d1078590c7 Fix: Testing backend bug where an entry was not properly rewritten
When moving an entry, what we did is copying the entry inside the
backend abstraction (the hashmap) from one key to another.

But as the entry itself does also encode its location, we actually have
to rewrite the entire entry. This patch fixes this.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26 09:57:05 +02:00
Matthias Beyer a07e03a25c Fix: Renaming entries should also remove the old entry
This is a bugfix for a bug in Store::move_entry_by_id():
The old entry was not removed after the new one was created.

The bug is a bit subtle. The issue was, that the internal cache held
open a reference to the old entry (as StoreEntry object) and when that
object got drop()ed, the contents of the entry were written to disk,
which resulted in the old entry being recreated.

This patch rewrites the function to behave well. The most critical part
is that we do not check whether the old entry is borrowed with
`hsmap.get()` but rather `hsmap.remove()`. The trick here is that the
`StoreEntry` object is dropped in the moment the check is done, clearing
the cached object and flushing it to the backend (the disk).
After that, we continue doing the filesystem operation and the cache is
clean.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-26 09:57:05 +02:00
Matthias Beyer a6bbcd65f4 Change output to not have quotes when printing string, int, float or bool
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-20 15:05:19 +02:00
Matthias Beyer eb85635bef Add trace output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-20 14:48:17 +02:00
Matthias Beyer 2a23002a07 Fix: --override-config argument can be passed multiple times
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-13 12:21:57 +02:00
Matthias Beyer cc0f2bf3de Fix: Add ID reporting
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-13 12:21:47 +02:00
Matthias Beyer b29afc2dda Add more debug output
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-13 12:21:41 +02:00
Matthias Beyer b7e996ccfe Merge branch 'imag-calendar/init' into master 2019-10-11 21:37:03 +02:00
Matthias Beyer f1ec71431e Implement show subcommand
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:44 +02:00
Matthias Beyer d40bf2956f Make helper type derive Debug
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:44 +02:00
Matthias Beyer d201797b98 Add argument to only list events after a certain date
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:44 +02:00
Matthias Beyer d9ac0c0b07 Add argument to only list events before a certain date
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:44 +02:00
Matthias Beyer 9801a3c295 Add helper function to parse string with kairos
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:44 +02:00
Matthias Beyer 81c6ee8314 Rewrite helper to be less complicated
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:44 +02:00
Matthias Beyer 3da1d9e1d9 Refactor to use new helper function
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:44 +02:00
Matthias Beyer 92a0713ed0 Add filtering for past events
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:43 +02:00
Matthias Beyer 14dc03f40f Enhance listing functionality with handlebars templating
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:26 +02:00
Matthias Beyer 8dbb2f1590 Add basic listing functionality
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:08 +02:00
Matthias Beyer 61f71d67cc Add example ref configuration for calendar
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:08 +02:00
Matthias Beyer 2e6df0e458 Add imag-calendar
This patch adds a imag-calendar command which features only a "import"
command by now.

This can be used to import calendar entries (events) to imag.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-11 21:36:08 +02:00
Matthias Beyer 712eda074d Merge branch 'libimagcalendar/init' into master 2019-10-11 21:35:51 +02:00
Matthias Beyer 33c355cd47 Merge branch 'is-linked-to' into master 2019-10-11 16:14:44 +02:00
Matthias Beyer b40a854c6f Add function to get all events
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-09 19:44:08 +02:00
Matthias Beyer e86f36c215 Add getter helper
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-09 19:44:08 +02:00
Matthias Beyer cf78f7192f Implement calendar library
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-09 19:44:08 +02:00
Matthias Beyer 3be9407c6c Add Linkable::is_linked_to()
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-09 19:44:01 +02:00
Matthias Beyer b2dffff6e8 Outsource helper: getting the link partial from Entry
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-09 19:44:01 +02:00
Matthias Beyer df5bfd1ce3 Merge branch 'minor' into master 2019-10-08 19:52:52 +02:00
Matthias Beyer 568e041c52 Update dependency: hex: 0.3.2 -> 0.4
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-07 18:18:28 +02:00
Matthias Beyer 613b78f369 Update dependency: ansi_term: 0.11.0 -> 0.12 2019-10-07 18:18:28 +02:00
Matthias Beyer 5edb470a5f Update dependency: handlebars: 1.1.0 -> 2 2019-10-07 18:18:28 +02:00
Matthias Beyer 07f949056e Update dependency: env_logger: 0.6.1 -> 0.7
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-07 18:18:28 +02:00
Matthias Beyer bddd29dfe4 Update dependency: indicatif: 0.11 -> 0.12 2019-10-07 18:06:29 +02:00
Matthias Beyer ee5348ea23 Update dependency: url: 1.7.2 -> 2
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-07 18:05:58 +02:00
Matthias Beyer d5b26a7ce7 Update minimum rust version to 1.36.0
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-06 11:18:40 +02:00
Matthias Beyer 7fc3961a17 Add viewer helper trait for iterators
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-04 17:50:30 +02:00
Matthias Beyer d8df96ad1f Merge branch 'imag-create' into master 2019-10-03 17:45:02 +02:00
Matthias Beyer f5a4331d0a Add helper function to parse string by several datetime formats
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-10-03 16:36:04 +02:00
Matthias Beyer fd3b46fa46 Add imag-create plumbing command for creating entries
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-09-28 19:55:35 +02:00
Matthias Beyer af6d67416b Fix typos 2019-09-20 19:16:22 +02:00
Matthias Beyer 2caeb0a510 Merge branch 'entry-find' into master 2019-09-01 13:37:18 +02:00
Matthias Beyer db3bb95227 Add user documentation
This patch adds user documentation in for of a mdbook, using a travis
job for running the build of the book in CI to be sure it builds
properly.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-09-01 13:37:05 +02:00
Matthias Beyer 87f2a0cb75 Add Tests for Entries::{find_by_id_substr, find_by_id_startswith} 2019-09-01 13:36:39 +02:00
Matthias Beyer 84135b1961 Add Entries::{find_by_id_substr, find_by_id_startswith}
This patch adds functions to the Entries type which can be used for
filtering by id, either with `contains()` or `starts_with()`.

This is useful for the end-user functionality where the user specifies
the ID of an entry only partially.

The implementation still iterates over all entries. This could be
improved, of course, by implementing a `find`-like function on `Store`
directly. But for now, this is good enough.

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-09-01 13:36:39 +02:00
Matthias Beyer 74810d9ccc Fix: Print processed IDs if output is not a pipe.
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-08-31 13:44:19 +02:00
Matthias Beyer 47044d9ffe Pull changes from https://github.com/flip1995/imag clippy_fix
This pulls in the clippy fixes from Phil. From the request-pull:

-----8<-----
    I finally got to fixing all of the Clippy warnings in the imag codebase.
    `cargo test` passes, `cargo clippy` doesn't produce any warnings
    or errors.

    Some important notes:
      - I didn't pay attention to the line length of the changes, so it may
        have happened that some lines are now longer than 100 chars
      - Except two commits the commit messages are formatted as follows:
        * The first tag shows if the changes in the commit were
          automatically applied by `cargo fix --clippy -Zunstable-options`.
          Commits that were automatically applied may require closer review,
          since I didn't check those by hand and the Clippy fix feature is
          still unstable.
        * The other tags specify the subcrate that is affected by the
          commit. I created one commit for each subcrate, even when only one
          file (most of the time the `main.rs` file) was changed.
      - I created one commit, where I replace usages of `r#try!` with the
        `?` operator, since `try!` is now officially deprecated.
      - I created one commit, where I just allow Clippy lints. Either because
        the fix would require much more work or knowledge of the codebase or
        because it was a FP.

    This was pretty much work, but it helped detecting a few bugs in Clippy,
    where I was already able to open 3 or 4 PRs. So win-win I guess.

    [...] we got a net LoC decrease.
----->8-----
2019-08-28 18:19:12 +02:00
flip1995 e2216db41d Allow some Clippy lints
Signed-off-by: flip1995 <hello@philkrones.com>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-08-28 18:18:41 +02:00
flip1995 0087de7af8 [No-auto] lib/etc/interaction: Fix Clippy warnings
Signed-off-by: flip1995 <hello@philkrones.com>
Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
2019-08-28 18:18:41 +02:00