mirror of
https://github.com/borgmatic-collective/borgmatic.git
synced 2026-07-22 02:03:01 +02:00
Fix a regression in which running borgmatic with no arguments and no configuration files doesn't error as expected (#1286).
This commit is contained in:
@@ -1,13 +1,16 @@
|
|||||||
2.1.4.dev0
|
2.1.4.dev0
|
||||||
* #1266: Add a stand-alone borgmatic Linux binary to the release downloads to serve as another way
|
* #1266: Add a stand-alone borgmatic Linux binary to the release downloads to serve as another way
|
||||||
to install borgmatic. Consider this binary a beta feature.
|
to install borgmatic. Consider this binary a beta feature.
|
||||||
|
* #1286: Fix a regression in which running borgmatic with no arguments and no configuration files
|
||||||
|
doesn't error as expected.
|
||||||
* When Borg exits with a warning exit code, show a description of it, so you don't have to lookup
|
* When Borg exits with a warning exit code, show a description of it, so you don't have to lookup
|
||||||
the code.
|
the code.
|
||||||
* Split out borgmatic installation documentation to its own page, so it's easier to find.
|
* Split out borgmatic installation documentation to its own page, so it's easier to find.
|
||||||
* Switch the default borgmatic installation method from pipx to uv, as uv is faster and used for
|
* Switch the default borgmatic installation method from pipx to uv, as uv is faster and used for
|
||||||
borgmatic development. If you'd like to switch, see the documentation for more information:
|
borgmatic development. If you'd like to switch, see the documentation for more information:
|
||||||
https://torsion.org/borgmatic/how-to/upgrade/
|
https://torsion.org/borgmatic/how-to/upgrade/
|
||||||
* Move project tracker from Gitea to Forgejo.
|
* Move the project tracker from Gitea to Forgejo.
|
||||||
|
* Fix a regression in which borgmatic didn't show an error message when run with no configuration.
|
||||||
|
|
||||||
2.1.3
|
2.1.3
|
||||||
* #1175: Add a "files_changed" option for customizing Borg's file modification detection.
|
* #1175: Add a "files_changed" option for customizing Borg's file modification detection.
|
||||||
|
|||||||
@@ -1044,16 +1044,17 @@ def exit_with_help_link(): # pragma: no cover
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def check_and_show_help_on_no_args(configs):
|
def check_and_show_help_on_no_args(configs, schema):
|
||||||
'''
|
'''
|
||||||
Given a dict of configuration filename to corresponding parsed configuration, check if the
|
Given a dict of configuration filename to corresponding parsed configuration and the
|
||||||
borgmatic command is run without any arguments. If the configuration option "default_actions" is
|
configuration schema as a dict, check if the borgmatic command was run without any arguments. If
|
||||||
set to False, show the help message. Otherwise, trigger the default backup behavior.
|
the configuration option "default_actions" is set to False, then show the help message an exit.
|
||||||
'''
|
'''
|
||||||
if len(sys.argv) == 1: # No arguments provided
|
if len(sys.argv) == 1: # No arguments provided.
|
||||||
default_actions = any(config.get('default_actions', True) for config in configs.values())
|
default_actions = any(config.get('default_actions', True) for config in configs.values())
|
||||||
if not default_actions:
|
|
||||||
parse_arguments('--help')
|
if configs and not default_actions:
|
||||||
|
parse_arguments(schema, '--help')
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
@@ -1150,8 +1151,7 @@ def main(extra_summary_logs=()): # pragma: no cover
|
|||||||
resolve_env=global_arguments.resolve_env and not arguments.get('validate'),
|
resolve_env=global_arguments.resolve_env and not arguments.get('validate'),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Use the helper function to check and show help on no arguments, passing the preloaded configs
|
check_and_show_help_on_no_args(configs, schema)
|
||||||
check_and_show_help_on_no_args(configs)
|
|
||||||
|
|
||||||
configuration_parse_errors = (
|
configuration_parse_errors = (
|
||||||
(max(log.levelno for log in parse_logs) >= logging.CRITICAL) if parse_logs else False
|
(max(log.levelno for log in parse_logs) >= logging.CRITICAL) if parse_logs else False
|
||||||
|
|||||||
@@ -1098,9 +1098,9 @@ properties:
|
|||||||
default_actions:
|
default_actions:
|
||||||
type: boolean
|
type: boolean
|
||||||
description: |
|
description: |
|
||||||
Whether to apply default actions (create, prune, compact and check)
|
Whether to run default actions (create, prune, compact, and check)
|
||||||
when no arguments are supplied to the borgmatic command. If set to
|
when no arguments are given on the command line. If set to false,
|
||||||
false, borgmatic displays the help message instead.
|
borgmatic displays the help message instead.
|
||||||
example: true
|
example: true
|
||||||
skip_actions:
|
skip_actions:
|
||||||
type: array
|
type: array
|
||||||
|
|||||||
+1
-1
@@ -49,7 +49,7 @@ source binary/bin/activate
|
|||||||
uv pip install -r binary_requirements.txt
|
uv pip install -r binary_requirements.txt
|
||||||
nuitka --mode=onefile --enable-plugin=upx --include-package-data=borgmatic --include-data-dir=borgmatic.egg-info=borgmatic.egg-info --include-package=borgmatic.hooks --include-package=apprise --no-deployment-flag=self-execution borgmatic/commands/borgmatic.py
|
nuitka --mode=onefile --enable-plugin=upx --include-package-data=borgmatic --include-data-dir=borgmatic.egg-info=borgmatic.egg-info --include-package=borgmatic.hooks --include-package=apprise --no-deployment-flag=self-execution borgmatic/commands/borgmatic.py
|
||||||
deactivate
|
deactivate
|
||||||
rm -fr binary
|
rm -fr binary borgmatic.build borgmatic.dist
|
||||||
standalone_binary_path="dist/borgmatic-${version}-binary-linux-glibc-x86_64"
|
standalone_binary_path="dist/borgmatic-${version}-binary-linux-glibc-x86_64"
|
||||||
mv borgmatic.bin "$standalone_binary_path"
|
mv borgmatic.bin "$standalone_binary_path"
|
||||||
|
|
||||||
|
|||||||
@@ -2582,23 +2582,40 @@ def test_collect_configuration_run_summary_logs_outputs_merged_json_results():
|
|||||||
|
|
||||||
def test_check_and_show_help_on_no_args_shows_help_when_no_args_and_default_actions_false():
|
def test_check_and_show_help_on_no_args_shows_help_when_no_args_and_default_actions_false():
|
||||||
flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
|
flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
|
||||||
flexmock(module).should_receive('parse_arguments').with_args('--help').once()
|
flexmock(module).should_receive('parse_arguments').with_args({}, '--help').once()
|
||||||
flexmock(module.sys).should_receive('exit').with_args(0).once()
|
flexmock(module.sys).should_receive('exit').with_args(0).once()
|
||||||
module.check_and_show_help_on_no_args({'test.yaml': {'default_actions': False}})
|
|
||||||
|
module.check_and_show_help_on_no_args(
|
||||||
|
configs={'test.yaml': {'default_actions': False}}, schema={}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def test_check_and_show_help_on_no_args_does_not_show_help_when_no_args_and_no_configurations():
|
||||||
|
flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
|
||||||
|
flexmock(module).should_receive('parse_arguments').never()
|
||||||
|
flexmock(module.sys).should_receive('exit').never()
|
||||||
|
|
||||||
|
module.check_and_show_help_on_no_args(configs={}, schema={})
|
||||||
|
|
||||||
|
|
||||||
def test_check_and_show_help_on_no_args_does_not_show_help_when_no_args_and_default_actions_true():
|
def test_check_and_show_help_on_no_args_does_not_show_help_when_no_args_and_default_actions_true():
|
||||||
flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
|
flexmock(module.sys).should_receive('argv').and_return(['borgmatic'])
|
||||||
flexmock(module).should_receive('parse_arguments').never()
|
flexmock(module).should_receive('parse_arguments').never()
|
||||||
flexmock(module.sys).should_receive('exit').never()
|
flexmock(module.sys).should_receive('exit').never()
|
||||||
module.check_and_show_help_on_no_args({'test.yaml': {'default_actions': True}})
|
|
||||||
|
module.check_and_show_help_on_no_args(
|
||||||
|
configs={'test.yaml': {'default_actions': True}}, schema={}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_check_and_show_help_on_no_args_does_not_show_help_when_args_provided():
|
def test_check_and_show_help_on_no_args_does_not_show_help_when_args_provided():
|
||||||
flexmock(module.sys).should_receive('argv').and_return(['borgmatic', '--create'])
|
flexmock(module.sys).should_receive('argv').and_return(['borgmatic', '--create'])
|
||||||
flexmock(module).should_receive('parse_arguments').never()
|
flexmock(module).should_receive('parse_arguments').never()
|
||||||
flexmock(module.sys).should_receive('exit').never()
|
flexmock(module.sys).should_receive('exit').never()
|
||||||
module.check_and_show_help_on_no_args({'test.yaml': {'default_actions': False}})
|
|
||||||
|
module.check_and_show_help_on_no_args(
|
||||||
|
configs={'test.yaml': {'default_actions': False}}, schema={}
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_check_and_show_help_on_no_args_with_no_default_actions_in_all_configs():
|
def test_check_and_show_help_on_no_args_with_no_default_actions_in_all_configs():
|
||||||
@@ -2611,10 +2628,10 @@ def test_check_and_show_help_on_no_args_with_no_default_actions_in_all_configs()
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Expect help to be shown
|
# Expect help to be shown
|
||||||
flexmock(module).should_receive('parse_arguments').with_args('--help').once()
|
flexmock(module).should_receive('parse_arguments').with_args({}, '--help').once()
|
||||||
flexmock(module.sys).should_receive('exit').with_args(0).once()
|
flexmock(module.sys).should_receive('exit').with_args(0).once()
|
||||||
|
|
||||||
module.check_and_show_help_on_no_args(configs)
|
module.check_and_show_help_on_no_args(configs=configs, schema={})
|
||||||
|
|
||||||
|
|
||||||
def test_check_and_show_help_on_no_args_with_conflicting_configs():
|
def test_check_and_show_help_on_no_args_with_conflicting_configs():
|
||||||
@@ -2630,7 +2647,7 @@ def test_check_and_show_help_on_no_args_with_conflicting_configs():
|
|||||||
flexmock(module).should_receive('parse_arguments').never()
|
flexmock(module).should_receive('parse_arguments').never()
|
||||||
flexmock(module.sys).should_receive('exit').never()
|
flexmock(module.sys).should_receive('exit').never()
|
||||||
|
|
||||||
module.check_and_show_help_on_no_args(configs)
|
module.check_and_show_help_on_no_args(configs=configs, schema={})
|
||||||
|
|
||||||
|
|
||||||
def test_get_singular_option_value_with_conflicting_values_exits():
|
def test_get_singular_option_value_with_conflicting_values_exits():
|
||||||
|
|||||||
Reference in New Issue
Block a user