From dcdbad35543b5396f4f1cbb39afc0b4abfd8d0ec Mon Sep 17 00:00:00 2001 From: Kyle Reynolds Date: Wed, 6 Mar 2024 07:26:53 -0700 Subject: [PATCH] bisync: clarify file operation directions in dry-run logs - fixes #7029 Before this change, NOTICE log messages during bisync dry runs were unclear as to the direction of the skipped operation (Path1 to 2 vs. 2 to 1.) This change adjusts the cmd/bisync/log.go indent function to be more expressive about direction. --- cmd/bisync/log.go | 4 ++ .../testdata/test_dry_run/golden/test.log | 48 +++++++++---------- .../test_filtersfile_checks/golden/test.log | 8 ++-- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/cmd/bisync/log.go b/cmd/bisync/log.go index 9d2e5b046..cd39079a6 100644 --- a/cmd/bisync/log.go +++ b/cmd/bisync/log.go @@ -29,6 +29,10 @@ func (b *bisyncRun) indent(tag, file, msg string) { logf = fs.Logf } + if b.opt.DryRun { + logf = fs.Logf + } + if tag == "Path1" { tag = Color(terminal.CyanFg, "Path1") } else { diff --git a/cmd/bisync/testdata/test_dry_run/golden/test.log b/cmd/bisync/testdata/test_dry_run/golden/test.log index 0eca08d1c..d51c7daa3 100644 --- a/cmd/bisync/testdata/test_dry_run/golden/test.log +++ b/cmd/bisync/testdata/test_dry_run/golden/test.log @@ -67,11 +67,11 @@ INFO : Bisyncing with Comparison Settings: } INFO : Synching Path1 "{path1/}" with Path2 "{path2/}" INFO : Copying Path2 files to Path1 -INFO : - Path2 Resync is copying files to - Path1 +NOTICE: - Path2 Resync is copying files to - Path1 NOTICE: file10.txt: Skipped copy as --dry-run is set (size 19) NOTICE: file4.txt: Skipped copy as --dry-run is set (size 0) NOTICE: file6.txt: Skipped copy as --dry-run is set (size 19) -INFO : - Path1 Resync is copying files to - Path2 +NOTICE: - Path1 Resync is copying files to - Path2 NOTICE: file1.txt: Skipped copy as --dry-run is set (size 0) NOTICE: file11.txt: Skipped copy as --dry-run is set (size 19) NOTICE: file2.txt: Skipped copy as --dry-run is set (size 13) @@ -97,21 +97,21 @@ INFO : Bisyncing with Comparison Settings: INFO : Synching Path1 "{path1/}" with Path2 "{path2/}" INFO : Building Path1 and Path2 listings INFO : Path1 checking for diffs -INFO : - Path1 File changed: size (larger), time (newer) - file2.txt -INFO : - Path1 File was deleted - file4.txt -INFO : - Path1 File changed: size (larger), time (newer) - file5.txt -INFO : - Path1 File was deleted - file6.txt -INFO : - Path1 File changed: size (larger), time (newer) - file7.txt -INFO : - Path1 File is new - file11.txt +NOTICE: - Path1 File changed: size (larger), time (newer) - file2.txt +NOTICE: - Path1 File was deleted - file4.txt +NOTICE: - Path1 File changed: size (larger), time (newer) - file5.txt +NOTICE: - Path1 File was deleted - file6.txt +NOTICE: - Path1 File changed: size (larger), time (newer) - file7.txt +NOTICE: - Path1 File is new - file11.txt INFO : Path1: 6 changes:  1 new,  3 modified,  2 deleted INFO : (Modified:  3 newer,  0 older,  3 larger,  0 smaller) INFO : Path2 checking for diffs -INFO : - Path2 File changed: size (larger), time (newer) - file1.txt -INFO : - Path2 File was deleted - file3.txt -INFO : - Path2 File changed: size (larger), time (newer) - file5.txt -INFO : - Path2 File changed: size (larger), time (newer) - file6.txt -INFO : - Path2 File was deleted - file7.txt -INFO : - Path2 File is new - file10.txt +NOTICE: - Path2 File changed: size (larger), time (newer) - file1.txt +NOTICE: - Path2 File was deleted - file3.txt +NOTICE: - Path2 File changed: size (larger), time (newer) - file5.txt +NOTICE: - Path2 File changed: size (larger), time (newer) - file6.txt +NOTICE: - Path2 File was deleted - file7.txt +NOTICE: - Path2 File is new - file10.txt INFO : Path2: 6 changes:  1 new,  3 modified,  2 deleted INFO : (Modified:  3 newer,  0 older,  3 larger,  0 smaller) INFO : Applying changes @@ -120,25 +120,25 @@ ERROR : file5.txt: md5 differ NOTICE: {path2String}: 1 differences found NOTICE: {path2String}: 1 errors while checking INFO : Finished checking the potential conflicts. 1 differences found -INFO : - Path1 Queue copy to Path2 - {path2/}file11.txt -INFO : - Path1 Queue copy to Path2 - {path2/}file2.txt -INFO : - Path2 Queue delete - {path2/}file4.txt +NOTICE: - Path1 Queue copy to Path2 - {path2/}file11.txt +NOTICE: - Path1 Queue copy to Path2 - {path2/}file2.txt +NOTICE: - Path2 Queue delete - {path2/}file4.txt NOTICE: - WARNING New or changed in both paths - file5.txt NOTICE: file5.txt: Skipped rename as --dry-run is set NOTICE: - Path1 Queue copy to Path2 - {path2/}file5.txt.conflict1 NOTICE: file5.txt: Skipped rename as --dry-run is set NOTICE: - Path2 Queue copy to Path1 - {path1/}file5.txt.conflict2 -INFO : - Path2 Queue copy to Path1 - {path1/}file6.txt -INFO : - Path1 Queue copy to Path2 - {path2/}file7.txt -INFO : - Path2 Queue copy to Path1 - {path1/}file1.txt -INFO : - Path2 Queue copy to Path1 - {path1/}file10.txt -INFO : - Path1 Queue delete - {path1/}file3.txt -INFO : - Path2 Do queued copies to - Path1 +NOTICE: - Path2 Queue copy to Path1 - {path1/}file6.txt +NOTICE: - Path1 Queue copy to Path2 - {path2/}file7.txt +NOTICE: - Path2 Queue copy to Path1 - {path1/}file1.txt +NOTICE: - Path2 Queue copy to Path1 - {path1/}file10.txt +NOTICE: - Path1 Queue delete - {path1/}file3.txt +NOTICE: - Path2 Do queued copies to - Path1 NOTICE: file1.txt: Skipped copy as --dry-run is set (size 19) NOTICE: file10.txt: Skipped copy as --dry-run is set (size 19) NOTICE: file3.txt: Skipped delete as --dry-run is set (size 0) NOTICE: file6.txt: Skipped copy as --dry-run is set (size 19) -INFO : - Path1 Do queued copies to - Path2 +NOTICE: - Path1 Do queued copies to - Path2 NOTICE: file11.txt: Skipped copy as --dry-run is set (size 19) NOTICE: file2.txt: Skipped copy as --dry-run is set (size 13) NOTICE: file4.txt: Skipped delete as --dry-run is set (size 0) diff --git a/cmd/bisync/testdata/test_filtersfile_checks/golden/test.log b/cmd/bisync/testdata/test_filtersfile_checks/golden/test.log index 28f4cfa89..6a2583402 100644 --- a/cmd/bisync/testdata/test_filtersfile_checks/golden/test.log +++ b/cmd/bisync/testdata/test_filtersfile_checks/golden/test.log @@ -153,11 +153,11 @@ INFO : Synching Path1 "{path1/}" with Path2 "{path2/}" INFO : Using filters file {workdir/}filtersfile.txt INFO : Skipped storing filters file hash to {workdir/}filtersfile.txt.md5 as --dry-run is set INFO : Copying Path2 files to Path1 -INFO : - Path2 Resync is copying files to - Path1 -NOTICE: subdir: Skipped set directory modification time as --dry-run is set (size 4Ki) +NOTICE: - Path2 Resync is copying files to - Path1 +NOTICE: subdir: Skipped set directory modification time as --dry-run is set NOTICE: {path1String}: Skipped set directory modification time as --dry-run is set -INFO : - Path1 Resync is copying files to - Path2 -NOTICE: subdir: Skipped set directory modification time as --dry-run is set (size 4Ki) +NOTICE: - Path1 Resync is copying files to - Path2 +NOTICE: subdir: Skipped set directory modification time as --dry-run is set NOTICE: {path2String}: Skipped set directory modification time as --dry-run is set INFO : Resync updating listings INFO : Bisync successful