2
0
Thomas Waldmann 8 сар өмнө
parent
commit
ae0e794355

+ 2 - 1
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)
 

+ 6 - 1
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.

+ 1 - 1
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")

+ 1 - 0
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: