Add tag to xml file when editing DayOne entry

This commit is contained in:
Jonathan van der Steege 2022-12-02 23:55:45 +01:00
parent c67084f396
commit 2decab0f67
2 changed files with 19 additions and 2 deletions

View file

@ -167,7 +167,7 @@ class DayOne(Journal.Journal):
return "\n".join([f"{str(e)}\n# {e.uuid}\n" for e in self.entries]) return "\n".join([f"{str(e)}\n# {e.uuid}\n" for e in self.entries])
def _update_old_entry(self, entry: Entry, new_entry: Entry) -> None: def _update_old_entry(self, entry: Entry, new_entry: Entry) -> None:
for attr in ("title", "body", "date"): for attr in ("title", "body", "date", "tags"):
old_attr = getattr(entry, attr) old_attr = getattr(entry, attr)
new_attr = getattr(new_entry, attr) new_attr = getattr(new_entry, attr)
if old_attr != new_attr: if old_attr != new_attr:

View file

@ -303,7 +303,7 @@ Feature: Writing new entries.
And we use the password "test" if prompted And we use the password "test" if prompted
And we append to the editor if opened And we append to the editor if opened
This is a small addendum to my latest entry. This is a small addendum to my latest entry.
When we run "jrnl --edit" When we run "jrnl --edit -1"
Then the output should contain Then the output should contain
1 entry modified 1 entry modified
@ -334,3 +334,20 @@ Feature: Writing new entries.
When we run "jrnl work This is a new entry" When we run "jrnl work This is a new entry"
Then the output should contain "Entry added to work journal" Then the output should contain "Entry added to work journal"
And we should get no error And we should get no error
Scenario Outline: Tags are saved when an entry is edited with --edit and can be searched afterward
Given we use the config "<config_file>"
And we use the password "test" if prompted
And we append to the editor if opened
@newtag
When we run "jrnl --edit -1"
When we run "jrnl --tags @newtag"
Then the output should contain
1 entry found
Examples: configs
| config_file |
| basic_onefile.yaml |
| basic_encrypted.yaml |
| basic_folder.yaml |
| basic_dayone.yaml |