diff --git a/docs/usage/repo-list.rst b/docs/usage/repo-list.rst index 00f9259087..e9fe6d65a4 100644 --- a/docs/usage/repo-list.rst +++ b/docs/usage/repo-list.rst @@ -5,9 +5,11 @@ Examples :: $ borg repo-list - Monday Mon, 2016-02-15 19:15:11 - repo Mon, 2016-02-15 19:26:54 - root-2016-02-15 Mon, 2016-02-15 19:36:29 - newname Mon, 2016-02-15 19:50:19 + 151b1a57 Mon, 2024-09-23 22:57:11 +0200 docs tw MacBook-Pro this is a comment + 3387a079 Thu, 2024-09-26 09:07:07 +0200 scripts tw MacBook-Pro + ca774425 Thu, 2024-09-26 10:05:23 +0200 scripts tw MacBook-Pro + ba56c4a5 Thu, 2024-09-26 10:12:45 +0200 src tw MacBook-Pro + 7567b79a Thu, 2024-09-26 10:15:07 +0200 scripts tw MacBook-Pro + 21ab3600 Thu, 2024-09-26 10:15:17 +0200 docs tw MacBook-Pro ... diff --git a/src/borg/archiver/repo_list_cmd.py b/src/borg/archiver/repo_list_cmd.py index 29682d30d9..6214c2ae06 100644 --- a/src/borg/archiver/repo_list_cmd.py +++ b/src/borg/archiver/repo_list_cmd.py @@ -20,9 +20,11 @@ def do_repo_list(self, args, repository, manifest): if args.format is not None: format = args.format elif args.short: - format = "{archive}{NL}" + format = "{id}{NL}" else: - format = os.environ.get("BORG_RLIST_FORMAT", "{archive:<36} {time} [{id}]{NL}") + format = os.environ.get( + "BORG_RLIST_FORMAT", "{id:.8} {time} {archive:<15} {username:<10} {hostname:<10} {comment:.40}{NL}" + ) formatter = ArchiveFormatter(format, repository, manifest, manifest.key, iec=args.iec) output_data = [] @@ -93,7 +95,7 @@ def build_parser_repo_list(self, subparsers, common_parser, mid_common_parser): ) subparser.set_defaults(func=self.do_repo_list) subparser.add_argument( - "--short", dest="short", action="store_true", help="only print the archive names, nothing else" + "--short", dest="short", action="store_true", help="only print the archive IDs, nothing else" ) subparser.add_argument( "--format", diff --git a/src/borg/testsuite/archiver/create_cmd.py b/src/borg/testsuite/archiver/create_cmd.py index d93a7652e2..08794a33e3 100644 --- a/src/borg/testsuite/archiver/create_cmd.py +++ b/src/borg/testsuite/archiver/create_cmd.py @@ -63,7 +63,7 @@ def test_basic_functionality(archivers, request): with changedir("output"): cmd(archiver, "extract", "test") - list_output = cmd(archiver, "repo-list", "--short") + list_output = cmd(archiver, "repo-list") assert "test" in list_output assert "test.2" in list_output @@ -532,7 +532,7 @@ def test_create_archivename_with_placeholder(archivers, request): name_given = "test-{now}" # placeholder in archive name gets replaced by borg name_expected = f"test-{ts}" # placeholder in f-string gets replaced by python cmd(archiver, "create", f"--timestamp={ts}", name_given, "input") - list_output = cmd(archiver, "repo-list", "--short") + list_output = cmd(archiver, "repo-list") assert name_expected in list_output diff --git a/src/borg/testsuite/archiver/repo_list_cmd.py b/src/borg/testsuite/archiver/repo_list_cmd.py index a8d87cb909..fc3b030678 100644 --- a/src/borg/testsuite/archiver/repo_list_cmd.py +++ b/src/borg/testsuite/archiver/repo_list_cmd.py @@ -25,13 +25,18 @@ def test_archives_format(archivers, request): cmd(archiver, "create", "--comment", "comment 1", "test-1", src_dir) cmd(archiver, "create", "--comment", "comment 2", "test-2", src_dir) output_1 = cmd(archiver, "repo-list") - output_2 = cmd(archiver, "repo-list", "--format", "{archive:<36} {time} [{id}]{NL}") + output_2 = cmd( + archiver, + "repo-list", + "--format", + "{id:.8} {time} {archive:<15} {username:<10} {hostname:<10} {comment:.40}{NL}", + ) assert output_1 == output_2 - output_1 = cmd(archiver, "repo-list", "--short") - assert output_1 == "test-1" + os.linesep + "test-2" + os.linesep - output_3 = cmd(archiver, "repo-list", "--format", "{name} {comment}{NL}") - assert "test-1 comment 1" + os.linesep in output_3 - assert "test-2 comment 2" + os.linesep in output_3 + output = cmd(archiver, "repo-list", "--short") + assert len(output) == 2 * 64 + 2 * len(os.linesep) + output = cmd(archiver, "repo-list", "--format", "{name} {comment}{NL}") + assert "test-1 comment 1" + os.linesep in output + assert "test-2 comment 2" + os.linesep in output def test_size_nfiles(archivers, request): diff --git a/src/borg/testsuite/archiver/transfer_cmd.py b/src/borg/testsuite/archiver/transfer_cmd.py index d178988ffe..84b9127e15 100644 --- a/src/borg/testsuite/archiver/transfer_cmd.py +++ b/src/borg/testsuite/archiver/transfer_cmd.py @@ -18,7 +18,7 @@ def test_transfer(archivers, request): original_location, input_path = archiver.repository_location, archiver.input_path def check_repo(): - listing = cmd(archiver, "repo-list", "--short") + listing = cmd(archiver, "repo-list") assert "arch1" in listing assert "arch2" in listing listing = cmd(archiver, "list", "--short", "arch1") @@ -93,6 +93,9 @@ def convert_tz(local_naive, tzoffset, tzinfo): for got_archive, expected_archive in zip(got["archives"], expected["archives"]): del got_archive["id"] + 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 expected_archive["id"] del expected_archive["barchive"] # timestamps: