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 diff --git a/CHANGELOG.md b/CHANGELOG.md index cb9699e1..f51438e3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,18 +1,26 @@ # 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:** - 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:** + +- 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:** - 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 +31,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)) 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/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/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/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 ", 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 == "." 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()