diff options
author | Jonathan van der Steege <jonathan@jonakeys.nl> | 2023-01-07 20:46:12 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-07 11:46:12 -0800 |
commit | d94325127f01f5d0b024a1cbd30350a68249754c (patch) | |
tree | c60d804097c175356091a4cf67f4c9c6913b5724 /jrnl | |
parent | fe08cfd3abdb161b6a529702333e6eb0cf6f04bc (diff) |
Update version key in config file after version changes (#1646)
Diffstat (limited to 'jrnl')
-rw-r--r-- | jrnl/install.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/jrnl/install.py b/jrnl/install.py index b5ec636e..5ae14f36 100644 --- a/jrnl/install.py +++ b/jrnl/install.py @@ -9,6 +9,7 @@ import sys from rich.pretty import pretty_repr +from jrnl import __version__ from jrnl.config import DEFAULT_JOURNAL_KEY from jrnl.config import get_config_path from jrnl.config import get_default_config @@ -32,12 +33,20 @@ def upgrade_config(config_data: dict, alt_config_path: str | None = None) -> Non """Checks if there are keys missing in a given config dict, and if so, updates the config file accordingly. This essentially automatically ports jrnl installations if new config parameters are introduced in later versions. + Also checks for existence of and difference in version number between config dict and current jrnl version, + and if so, update the config file accordingly. Supply alt_config_path if using an alternate config through --config-file.""" default_config = get_default_config() missing_keys = set(default_config).difference(config_data) if missing_keys: for key in missing_keys: config_data[key] = default_config[key] + + different_version = (config_data["version"] != __version__) + if different_version: + config_data["version"] = __version__ + + if missing_keys or different_version: save_config(config_data, alt_config_path) config_path = alt_config_path if alt_config_path else get_config_path() print_msg( |