Merge branch 'develop' into encryption-rework

This commit is contained in:
Jonathan Wren 2022-10-08 16:00:19 -07:00
commit a9f57a0ce9
9 changed files with 49 additions and 19 deletions

4
.gitignore vendored
View file

@ -17,10 +17,12 @@ sdist/
.tox/
var/
node_modules/
__pycache__/
.pytest_cache/
# Versioning
.python-version
.tool-version
.tool-versions
# Installer logs
.DS_Store

View file

@ -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))

View file

@ -1 +1 @@
__version__ = "v3.2"
__version__ = "v3.3-beta"

View file

@ -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,

View file

@ -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:

View file

@ -31,8 +31,9 @@ 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))
f.write(export_str)
print_msg(
Message(
MsgText.JournalExportedTo,

View file

@ -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 <maintainers@jrnl.sh>",

View file

@ -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 == "."

View file

@ -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()