Skip to content

Commit 3d15c51

Browse files
committed
Fix the "--repository" flag not applying to command hooks (#1176).
1 parent f9206c1 commit 3d15c51

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+362
-747
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
snapshot paths were ignored.
1111
* #1170: Fix for an inconsistent log level for Borg's last output line before exiting.
1212
* #1172: Add an "environment" option to the Sentry monitoring hook.
13+
* #1176: Fix the "--repository" flag not applying to command hooks.
1314
* Add a "rename" option to "extra_borg_options" to support passing arbitrary flags to "borg
1415
rename".
1516
* Add documentation on patterns and excludes:

borgmatic/actions/borg.py

Lines changed: 19 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import borgmatic.borg.borg
44
import borgmatic.borg.repo_list
5-
import borgmatic.config.validate
65

76
logger = logging.getLogger(__name__)
87

@@ -19,26 +18,22 @@ def run_borg(
1918
'''
2019
Run the "borg" action for the given repository.
2120
'''
22-
if borg_arguments.repository is None or borgmatic.config.validate.repositories_match(
23-
repository,
24-
borg_arguments.repository,
25-
):
26-
logger.info('Running arbitrary Borg command')
27-
archive_name = borgmatic.borg.repo_list.resolve_archive_name(
28-
repository['path'],
29-
borg_arguments.archive,
30-
config,
31-
local_borg_version,
32-
global_arguments,
33-
local_path,
34-
remote_path,
35-
)
36-
borgmatic.borg.borg.run_arbitrary_borg(
37-
repository['path'],
38-
config,
39-
local_borg_version,
40-
options=borg_arguments.options,
41-
archive=archive_name,
42-
local_path=local_path,
43-
remote_path=remote_path,
44-
)
21+
logger.info('Running arbitrary Borg command')
22+
archive_name = borgmatic.borg.repo_list.resolve_archive_name(
23+
repository['path'],
24+
borg_arguments.archive,
25+
config,
26+
local_borg_version,
27+
global_arguments,
28+
local_path,
29+
remote_path,
30+
)
31+
borgmatic.borg.borg.run_arbitrary_borg(
32+
repository['path'],
33+
config,
34+
local_borg_version,
35+
options=borg_arguments.options,
36+
archive=archive_name,
37+
local_path=local_path,
38+
remote_path=remote_path,
39+
)

borgmatic/actions/break_lock.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22

33
import borgmatic.borg.break_lock
4-
import borgmatic.config.validate
54

65
logger = logging.getLogger(__name__)
76

@@ -18,16 +17,12 @@ def run_break_lock(
1817
'''
1918
Run the "break-lock" action for the given repository.
2019
'''
21-
if break_lock_arguments.repository is None or borgmatic.config.validate.repositories_match(
22-
repository,
23-
break_lock_arguments.repository,
24-
):
25-
logger.info('Breaking repository and cache locks')
26-
borgmatic.borg.break_lock.break_lock(
27-
repository['path'],
28-
config,
29-
local_borg_version,
30-
global_arguments,
31-
local_path=local_path,
32-
remote_path=remote_path,
33-
)
20+
logger.info('Breaking repository and cache locks')
21+
borgmatic.borg.break_lock.break_lock(
22+
repository['path'],
23+
config,
24+
local_borg_version,
25+
global_arguments,
26+
local_path=local_path,
27+
remote_path=remote_path,
28+
)
Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22

33
import borgmatic.borg.change_passphrase
4-
import borgmatic.config.validate
54

65
logger = logging.getLogger(__name__)
76

@@ -18,20 +17,13 @@ def run_change_passphrase(
1817
'''
1918
Run the "key change-passphrase" action for the given repository.
2019
'''
21-
if (
22-
change_passphrase_arguments.repository is None
23-
or borgmatic.config.validate.repositories_match(
24-
repository,
25-
change_passphrase_arguments.repository,
26-
)
27-
):
28-
logger.info('Changing repository passphrase')
29-
borgmatic.borg.change_passphrase.change_passphrase(
30-
repository['path'],
31-
config,
32-
local_borg_version,
33-
change_passphrase_arguments,
34-
global_arguments,
35-
local_path=local_path,
36-
remote_path=remote_path,
37-
)
20+
logger.info('Changing repository passphrase')
21+
borgmatic.borg.change_passphrase.change_passphrase(
22+
repository['path'],
23+
config,
24+
local_borg_version,
25+
change_passphrase_arguments,
26+
global_arguments,
27+
local_path=local_path,
28+
remote_path=remote_path,
29+
)

borgmatic/actions/check.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import borgmatic.borg.repo_list
2323
import borgmatic.borg.state
2424
import borgmatic.config.paths
25-
import borgmatic.config.validate
2625
import borgmatic.execute
2726
import borgmatic.hooks.command
2827

@@ -750,12 +749,6 @@ def run_check(
750749
751750
Raise ValueError if the Borg repository ID cannot be determined.
752751
'''
753-
if check_arguments.repository and not borgmatic.config.validate.repositories_match(
754-
repository,
755-
check_arguments.repository,
756-
):
757-
return
758-
759752
logger.info('Running consistency checks')
760753

761754
repository_id = borgmatic.borg.check.get_repository_id(

borgmatic/actions/compact.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import borgmatic.borg.compact
44
import borgmatic.borg.feature
5-
import borgmatic.config.validate
65
import borgmatic.hooks.command
76

87
logger = logging.getLogger(__name__)
@@ -22,12 +21,6 @@ def run_compact(
2221
'''
2322
Run the "compact" action for the given repository.
2423
'''
25-
if compact_arguments.repository and not borgmatic.config.validate.repositories_match(
26-
repository,
27-
compact_arguments.repository,
28-
):
29-
return
30-
3124
if borgmatic.borg.feature.available(borgmatic.borg.feature.Feature.COMPACT, local_borg_version):
3225
logger.info(f'Compacting segments{dry_run_label}')
3326
borgmatic.borg.compact.compact_segments(

borgmatic/actions/config/bootstrap.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
import borgmatic.borg.extract
66
import borgmatic.borg.repo_list
77
import borgmatic.config.paths
8-
import borgmatic.config.validate
98
import borgmatic.hooks.command
109

1110
logger = logging.getLogger(__name__)

borgmatic/actions/create.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import borgmatic.borg.rename
77
import borgmatic.borg.repo_list
88
import borgmatic.config.paths
9-
import borgmatic.config.validate
109
import borgmatic.hooks.dispatch
1110
from borgmatic.actions import pattern
1211

@@ -30,12 +29,6 @@ def run_create(
3029
3130
If create_arguments.json is True, yield the JSON output from creating the archive.
3231
'''
33-
if create_arguments.repository and not borgmatic.config.validate.repositories_match(
34-
repository,
35-
create_arguments.repository,
36-
):
37-
return
38-
3932
if config.get('list_details') and config.get('progress'):
4033
raise ValueError(
4134
'With the create action, only one of --list/--files/list_details and --progress/progress can be used.',

borgmatic/actions/delete.py

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,28 @@ def run_delete(
2020
'''
2121
Run the "delete" action for the given repository and archive(s).
2222
'''
23-
if delete_arguments.repository is None or borgmatic.config.validate.repositories_match(
24-
repository,
25-
delete_arguments.repository,
26-
):
27-
logger.answer('Deleting archives')
28-
29-
archive_name = (
30-
borgmatic.borg.repo_list.resolve_archive_name(
31-
repository['path'],
32-
delete_arguments.archive,
33-
config,
34-
local_borg_version,
35-
global_arguments,
36-
local_path,
37-
remote_path,
38-
)
39-
if delete_arguments.archive
40-
else None
41-
)
23+
logger.answer('Deleting archives')
4224

43-
borgmatic.borg.delete.delete_archives(
44-
repository,
25+
archive_name = (
26+
borgmatic.borg.repo_list.resolve_archive_name(
27+
repository['path'],
28+
delete_arguments.archive,
4529
config,
4630
local_borg_version,
47-
borgmatic.actions.arguments.update_arguments(delete_arguments, archive=archive_name),
4831
global_arguments,
4932
local_path,
5033
remote_path,
5134
)
35+
if delete_arguments.archive
36+
else None
37+
)
38+
39+
borgmatic.borg.delete.delete_archives(
40+
repository,
41+
config,
42+
local_borg_version,
43+
borgmatic.actions.arguments.update_arguments(delete_arguments, archive=archive_name),
44+
global_arguments,
45+
local_path,
46+
remote_path,
47+
)

borgmatic/actions/export_key.py

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import logging
22

33
import borgmatic.borg.export_key
4-
import borgmatic.config.validate
54

65
logger = logging.getLogger(__name__)
76

@@ -18,17 +17,13 @@ def run_export_key(
1817
'''
1918
Run the "key export" action for the given repository.
2019
'''
21-
if export_arguments.repository is None or borgmatic.config.validate.repositories_match(
22-
repository,
23-
export_arguments.repository,
24-
):
25-
logger.info('Exporting repository key')
26-
borgmatic.borg.export_key.export_key(
27-
repository['path'],
28-
config,
29-
local_borg_version,
30-
export_arguments,
31-
global_arguments,
32-
local_path=local_path,
33-
remote_path=remote_path,
34-
)
20+
logger.info('Exporting repository key')
21+
borgmatic.borg.export_key.export_key(
22+
repository['path'],
23+
config,
24+
local_borg_version,
25+
export_arguments,
26+
global_arguments,
27+
local_path=local_path,
28+
remote_path=remote_path,
29+
)

0 commit comments

Comments
 (0)