From ae0e794355fe7d036eca1063ac22e6b2a4706009 Mon Sep 17 00:00:00 2001 From: Thomas Waldmann Date: Thu, 3 Oct 2024 00:15:04 +0200 Subject: [PATCH] repo-list: show tags --- src/borg/archiver/repo_list_cmd.py | 3 ++- src/borg/helpers/parseformat.py | 7 ++++++- src/borg/testsuite/archiver/repo_list_cmd.py | 2 +- src/borg/testsuite/archiver/transfer_cmd.py | 1 + 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/borg/archiver/repo_list_cmd.py b/src/borg/archiver/repo_list_cmd.py index 6214c2ae0..752b706f2 100644 --- a/src/borg/archiver/repo_list_cmd.py +++ b/src/borg/archiver/repo_list_cmd.py @@ -23,7 +23,8 @@ class RepoListMixIn: format = "{id}{NL}" else: format = os.environ.get( - "BORG_RLIST_FORMAT", "{id:.8} {time} {archive:<15} {username:<10} {hostname:<10} {comment:.40}{NL}" + "BORG_RLIST_FORMAT", + "{id:.8} {time} {archive:<15} {tags:<10} {username:<10} {hostname:<10} {comment:.40}{NL}", ) formatter = ArchiveFormatter(format, repository, manifest, manifest.key, iec=args.iec) diff --git a/src/borg/helpers/parseformat.py b/src/borg/helpers/parseformat.py index b43397f33..5bffa6fe3 100644 --- a/src/borg/helpers/parseformat.py +++ b/src/borg/helpers/parseformat.py @@ -771,6 +771,7 @@ class ArchiveFormatter(BaseFormatter): "archive": "archive name", "name": 'alias of "archive"', "comment": "archive comment", + "tags": "archive tags", # *start* is the key used by borg-info for this timestamp, this makes the formats more compatible "start": "time (start) of creation of the archive", "time": 'alias of "start"', @@ -783,7 +784,7 @@ class ArchiveFormatter(BaseFormatter): "nfiles": "count of files in this archive", } KEY_GROUPS = ( - ("archive", "name", "comment", "id"), + ("archive", "name", "comment", "id", "tags"), ("start", "time", "end", "command_line"), ("hostname", "username"), ("size", "nfiles"), @@ -809,6 +810,7 @@ class ArchiveFormatter(BaseFormatter): "size": partial(self.get_meta, "size", 0), "nfiles": partial(self.get_meta, "nfiles", 0), "end": self.get_ts_end, + "tags": self.get_tags, } self.used_call_keys = set(self.call_keys) & self.format_keys @@ -854,6 +856,9 @@ class ArchiveFormatter(BaseFormatter): def format_time(self, ts): return OutputTimestamp(ts) + def get_tags(self): + return ",".join(sorted(self.archive.tags)) + class ItemFormatter(BaseFormatter): # we provide the hash algos from python stdlib (except shake_*) and additionally xxh64. diff --git a/src/borg/testsuite/archiver/repo_list_cmd.py b/src/borg/testsuite/archiver/repo_list_cmd.py index fc3b03067..ffce5af00 100644 --- a/src/borg/testsuite/archiver/repo_list_cmd.py +++ b/src/borg/testsuite/archiver/repo_list_cmd.py @@ -29,7 +29,7 @@ def test_archives_format(archivers, request): archiver, "repo-list", "--format", - "{id:.8} {time} {archive:<15} {username:<10} {hostname:<10} {comment:.40}{NL}", + "{id:.8} {time} {archive:<15} {tags:<10} {username:<10} {hostname:<10} {comment:.40}{NL}", ) assert output_1 == output_2 output = cmd(archiver, "repo-list", "--short") diff --git a/src/borg/testsuite/archiver/transfer_cmd.py b/src/borg/testsuite/archiver/transfer_cmd.py index 84b9127e1..3ff2616f7 100644 --- a/src/borg/testsuite/archiver/transfer_cmd.py +++ b/src/borg/testsuite/archiver/transfer_cmd.py @@ -96,6 +96,7 @@ def test_transfer_upgrade(archivers, request): del got_archive["username"] # we didn't have this in the 1.x default format del got_archive["hostname"] # we didn't have this in the 1.x default format del got_archive["comment"] # we didn't have this in the 1.x default format + del got_archive["tags"] # we didn't have this in the 1.x default format del expected_archive["id"] del expected_archive["barchive"] # timestamps: