Merge branch 'master' of floli/borgmatic into master
This commit is contained in:
commit
6db3e1dda5
4 changed files with 26 additions and 4 deletions
1
NEWS
1
NEWS
|
@ -8,6 +8,7 @@
|
|||
* #88: Fix declared pykwalify compatibility version range in setup.py to prevent use of ancient
|
||||
versions of pykwalify with large version numbers.
|
||||
* #89: Pass --show-rc option to Borg when at highest verbosity level.
|
||||
* #94: Add --json option for --create option.
|
||||
|
||||
1.2.2
|
||||
* #85: Fix compatibility issue between pykwalify and ruamel.yaml 0.15.52, which manifested in
|
||||
|
|
|
@ -103,8 +103,7 @@ def _make_exclude_flags(location_config, exclude_filename=None):
|
|||
|
||||
|
||||
def create_archive(
|
||||
dry_run, repository, location_config, storage_config, local_path='borg', remote_path=None,
|
||||
):
|
||||
dry_run, repository, location_config, storage_config, local_path='borg', remote_path=None, json=False):
|
||||
'''
|
||||
Given vebosity/dry-run flags, a local or remote repository path, a location config dict, and a
|
||||
storage config dict, create a Borg archive.
|
||||
|
@ -154,6 +153,7 @@ def create_archive(
|
|||
+ (('--stats',) if not dry_run and logger.isEnabledFor(logging.INFO) else ())
|
||||
+ (('--debug', '--show-rc') if logger.isEnabledFor(logging.DEBUG) else ())
|
||||
+ (('--dry-run',) if dry_run else ())
|
||||
+ (('--json',) if json else ())
|
||||
)
|
||||
|
||||
logger.debug(' '.join(full_command))
|
||||
|
|
|
@ -99,8 +99,8 @@ def parse_arguments(*arguments):
|
|||
|
||||
args = parser.parse_args(arguments)
|
||||
|
||||
if args.json and not (args.list or args.info):
|
||||
raise ValueError('The --json option can only be used with the --list or --info options')
|
||||
if args.json and not (args.create or args.list or args.info):
|
||||
raise ValueError('The --json option can only be used with the --create, --list or --info options')
|
||||
|
||||
if args.json and args.list and args.info:
|
||||
raise ValueError(
|
||||
|
@ -192,6 +192,7 @@ def _run_commands_on_repository(
|
|||
consistency,
|
||||
local_path=local_path,
|
||||
remote_path=remote_path,
|
||||
json=args.json
|
||||
)
|
||||
if args.list:
|
||||
logger.info('{}: Listing archives'.format(repository))
|
||||
|
|
|
@ -609,6 +609,26 @@ def test_create_archive_with_lock_wait_calls_borg_with_lock_wait_parameters():
|
|||
)
|
||||
|
||||
|
||||
def test_create_archive_with_json_calls_borg_with_json_parameter():
|
||||
flexmock(module).should_receive('_expand_directories').and_return(('foo', 'bar')).and_return(())
|
||||
flexmock(module).should_receive('_write_pattern_file').and_return(None)
|
||||
flexmock(module).should_receive('_make_pattern_flags').and_return(())
|
||||
flexmock(module).should_receive('_make_exclude_flags').and_return(())
|
||||
insert_subprocess_mock(CREATE_COMMAND + ('--json',))
|
||||
|
||||
module.create_archive(
|
||||
dry_run=False,
|
||||
repository='repo',
|
||||
location_config={
|
||||
'source_directories': ['foo', 'bar'],
|
||||
'repositories': ['repo'],
|
||||
'exclude_patterns': None,
|
||||
},
|
||||
storage_config={},
|
||||
json=True
|
||||
)
|
||||
|
||||
|
||||
def test_create_archive_with_source_directories_glob_expands():
|
||||
flexmock(module).should_receive('_expand_directories').and_return(('foo', 'food')).and_return(())
|
||||
flexmock(module).should_receive('_write_pattern_file').and_return(None)
|
||||
|
|
Loading…
Reference in a new issue