From ff24ee604d3385bdcc821c9c4fe2c1dbc33e149d Mon Sep 17 00:00:00 2001 From: Jonathan Wren Date: Sat, 8 Oct 2022 12:40:27 -0700 Subject: [PATCH 1/7] Update `.gitignore` (#1604) * add ignore for directories used by this project * update name of asdf version file (had a typo) --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 186ef3ac..65018206 100644 --- a/.gitignore +++ b/.gitignore @@ -17,10 +17,12 @@ sdist/ .tox/ var/ node_modules/ +__pycache__/ +.pytest_cache/ # Versioning .python-version -.tool-version +.tool-versions # Installer logs .DS_Store From dd7f59cef7844f281001af809dc525731c1f6510 Mon Sep 17 00:00:00 2001 From: Jrnl Bot Date: Sat, 8 Oct 2022 19:42:07 +0000 Subject: [PATCH 2/7] Update changelog [ci skip] --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb9699e1..92724355 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,9 +10,14 @@ - Add machine-readable format for --list [\#1445](https://github.com/jrnl-org/jrnl/issues/1445) - Add machine readable --list output [\#1592](https://github.com/jrnl-org/jrnl/pull/1592) ([apainintheneck](https://github.com/apainintheneck)) +**Fixed bugs:** + +- Bug Report - Sometimes jrnl crashes and truncates journal file [\#1599](https://github.com/jrnl-org/jrnl/issues/1599) + **Build:** - Replace Dependabot [\#1560](https://github.com/jrnl-org/jrnl/issues/1560) +- Update `.gitignore` [\#1604](https://github.com/jrnl-org/jrnl/pull/1604) ([wren](https://github.com/wren)) - Fix Docs Accessibility Testing [\#1588](https://github.com/jrnl-org/jrnl/pull/1588) ([wren](https://github.com/wren)) - Update to use renamed flag for `brew bump-formula-pr` [\#1587](https://github.com/jrnl-org/jrnl/pull/1587) ([wren](https://github.com/wren)) - Update peter-evans/create-pull-request action to v4 [\#1585](https://github.com/jrnl-org/jrnl/pull/1585) ([renovate[bot]](https://github.com/apps/renovate)) @@ -23,6 +28,7 @@ **Documentation:** +- \[Documentation\] Edit on Github link broken [\#1601](https://github.com/jrnl-org/jrnl/issues/1601) - Update `--format yaml` example in docs [\#1525](https://github.com/jrnl-org/jrnl/issues/1525) - Update YAML export description in docs [\#1591](https://github.com/jrnl-org/jrnl/pull/1591) ([apainintheneck](https://github.com/apainintheneck)) - Update dependency jinja2 to v3.1.2 [\#1579](https://github.com/jrnl-org/jrnl/pull/1579) ([renovate[bot]](https://github.com/apps/renovate)) From ceff398a01f4c357f77bd168b5e147ff89d0718e Mon Sep 17 00:00:00 2001 From: Micah Jerome Ellison Date: Sat, 8 Oct 2022 13:41:22 -0700 Subject: [PATCH 3/7] Change default config to use journal key instead of journal name as key for file path (#1594) --- jrnl/config.py | 2 +- jrnl/install.py | 4 ++-- tests/lib/then_steps.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/jrnl/config.py b/jrnl/config.py index c8d5902c..aed17200 100644 --- a/jrnl/config.py +++ b/jrnl/config.py @@ -91,7 +91,7 @@ def get_config_path(): def get_default_config(): return { "version": __version__, - "journals": {"default": get_default_journal_path()}, + "journals": {"default": {"journal": get_default_journal_path()}}, "editor": os.getenv("VISUAL") or os.getenv("EDITOR") or "", "encrypt": False, "template": False, diff --git a/jrnl/install.py b/jrnl/install.py index a4797dc7..b20685f0 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -122,10 +122,10 @@ def install(): ) journal_path = absolute_path(user_given_path or default_journal_path) default_config = get_default_config() - default_config["journals"][DEFAULT_JOURNAL_KEY] = journal_path + default_config["journals"][DEFAULT_JOURNAL_KEY]["journal"] = journal_path # If the folder doesn't exist, create it - path = os.path.split(default_config["journals"][DEFAULT_JOURNAL_KEY])[0] + path = os.path.split(journal_path)[0] try: os.makedirs(path) except OSError: diff --git a/tests/lib/then_steps.py b/tests/lib/then_steps.py index cb7e9766..61916262 100644 --- a/tests/lib/then_steps.py +++ b/tests/lib/then_steps.py @@ -118,7 +118,7 @@ def output_should_be_columns_wide(cli_run, width): ) ) def default_journal_location(journal_file, journal_dir, config_on_disk, temp_dir): - default_journal_path = config_on_disk["journals"]["default"] + default_journal_path = config_on_disk["journals"]["default"]["journal"] expected_journal_path = ( os.path.join(temp_dir.name, journal_file) if journal_dir == "." From a925c81ba8acad9bdc03a86d24af521f66b48e74 Mon Sep 17 00:00:00 2001 From: Jrnl Bot Date: Sat, 8 Oct 2022 20:43:20 +0000 Subject: [PATCH 4/7] Update changelog [ci skip] --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 92724355..e9883d48 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ - Add dependency security checks in CI [\#1488](https://github.com/jrnl-org/jrnl/issues/1488) - Add machine-readable format for --list [\#1445](https://github.com/jrnl-org/jrnl/issues/1445) +- Change default config to use journal key [\#1594](https://github.com/jrnl-org/jrnl/pull/1594) ([micahellison](https://github.com/micahellison)) - Add machine readable --list output [\#1592](https://github.com/jrnl-org/jrnl/pull/1592) ([apainintheneck](https://github.com/apainintheneck)) **Fixed bugs:** From d7242d81a463b790f6650a18fce2b8047d776fbc Mon Sep 17 00:00:00 2001 From: outa Date: Sat, 8 Oct 2022 22:48:29 +0200 Subject: [PATCH 5/7] Don't create empty file when attempting a YAML export to a non-existing folder (#1600) * Call `export_journal` before opening file handle * Use correct exporter class * Fix unit test --- jrnl/plugins/text_exporter.py | 21 +++++++++++---------- tests/unit/test_export.py | 18 ++++++++++++++++++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/jrnl/plugins/text_exporter.py b/jrnl/plugins/text_exporter.py index 931305ef..4451cfef 100644 --- a/jrnl/plugins/text_exporter.py +++ b/jrnl/plugins/text_exporter.py @@ -31,18 +31,19 @@ class TextExporter: @classmethod def write_file(cls, journal, path): """Exports a journal into a single file.""" + export_str = cls.export_journal(journal) with open(path, "w", encoding="utf-8") as f: - f.write(cls.export_journal(journal)) - print_msg( - Message( - MsgText.JournalExportedTo, - MsgStyle.NORMAL, - { - "path": path, - }, - ) + f.write(export_str) + print_msg( + Message( + MsgText.JournalExportedTo, + MsgStyle.NORMAL, + { + "path": path, + }, ) - return "" + ) + return "" @classmethod def make_filename(cls, entry): diff --git a/tests/unit/test_export.py b/tests/unit/test_export.py index 27e60d80..1fd8663e 100644 --- a/tests/unit/test_export.py +++ b/tests/unit/test_export.py @@ -1,10 +1,16 @@ # Copyright © 2012-2022 jrnl contributors # License: https://www.gnu.org/licenses/gpl-3.0.html +from unittest import mock + import pytest from jrnl.exception import JrnlException +from jrnl.messages import Message +from jrnl.messages import MsgStyle +from jrnl.messages import MsgText from jrnl.plugins.fancy_exporter import check_provided_linewrap_viability +from jrnl.plugins.yaml_exporter import YAMLExporter @pytest.fixture() @@ -28,3 +34,15 @@ class TestFancy: with pytest.raises(JrnlException): check_provided_linewrap_viability(total_linewrap, [content], journal) + + +class TestYaml: + @mock.patch("jrnl.plugins.yaml_exporter.YAMLExporter.export_journal") + @mock.patch("builtins.open") + def test_export_to_nonexisting_folder(self, mock_open, mock_export_journal): + mock_export_journal.side_effect = JrnlException( + Message(MsgText.YamlMustBeDirectory, MsgStyle.ERROR) + ) + with pytest.raises(JrnlException): + YAMLExporter.write_file("journal", "non-existing-path") + mock_open.assert_not_called() From 41e5d5ffffc3c28be9aaca05ddafd5f681fbf600 Mon Sep 17 00:00:00 2001 From: Jrnl Bot Date: Sat, 8 Oct 2022 20:49:59 +0000 Subject: [PATCH 6/7] Increment version to v3.3-beta --- jrnl/__version__.py | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/jrnl/__version__.py b/jrnl/__version__.py index 9c1e3fb9..519d4206 100644 --- a/jrnl/__version__.py +++ b/jrnl/__version__.py @@ -1 +1 @@ -__version__ = "v3.2" +__version__ = "v3.3-beta" diff --git a/pyproject.toml b/pyproject.toml index ffeb8b27..79b232b7 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "jrnl" -version = "v3.2" +version = "v3.3-beta" description = "Collect your thoughts and notes without leaving the command line." authors = [ "jrnl contributors ", From 52f82fc855daa625a0e2d36597e191a3b6f5be15 Mon Sep 17 00:00:00 2001 From: Jrnl Bot Date: Sat, 8 Oct 2022 20:51:42 +0000 Subject: [PATCH 7/7] Update changelog [ci skip] --- CHANGELOG.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9883d48..f51438e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,8 @@ # Changelog -## [Unreleased](https://github.com/jrnl-org/jrnl/) +## [v3.3-beta](https://pypi.org/project/jrnl/v3.3-beta/) (2022-10-08) -[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.2...HEAD) +[Full Changelog](https://github.com/jrnl-org/jrnl/compare/v3.2...v3.3-beta) **Implemented enhancements:** @@ -14,6 +14,8 @@ **Fixed bugs:** - Bug Report - Sometimes jrnl crashes and truncates journal file [\#1599](https://github.com/jrnl-org/jrnl/issues/1599) +- Zero-length file created when attempting to export YAML to a directory that does not exist [\#1593](https://github.com/jrnl-org/jrnl/issues/1593) +- Don't create empty file when attempting a YAML export to a non-existing folder [\#1600](https://github.com/jrnl-org/jrnl/pull/1600) ([outa](https://github.com/outa)) **Build:**