diff --git a/commands/command_checkout.go b/commands/command_checkout.go index 32b368d1..122f2460 100644 --- a/commands/command_checkout.go +++ b/commands/command_checkout.go @@ -39,6 +39,7 @@ func checkoutCommand(cmd *cobra.Command, args []string) { var pointers []*lfs.WrappedPointer logger := tasklog.NewLogger(os.Stdout) meter := tq.NewMeter() + meter.Direction = tq.Checkout meter.Logger = meter.LoggerFromEnv(cfg.Os) logger.Enqueue(meter) chgitscanner := lfs.NewGitScanner(func(p *lfs.WrappedPointer, err error) { diff --git a/test/test-checkout.sh b/test/test-checkout.sh index ef0ee6ae..cd2633c8 100755 --- a/test/test-checkout.sh +++ b/test/test-checkout.sh @@ -41,12 +41,13 @@ begin_test "checkout" rm -rf file1.dat file2.dat file3.dat folder1/nested.dat folder2/nested.dat echo "checkout should replace all" - git lfs checkout + git lfs checkout 2>&1 | tee checkout.log [ "$contents" = "$(cat file1.dat)" ] [ "$contents" = "$(cat file2.dat)" ] [ "$contents" = "$(cat file3.dat)" ] [ "$contents" = "$(cat folder1/nested.dat)" ] [ "$contents" = "$(cat folder2/nested.dat)" ] + grep "Checking out LFS objects: 100% (5/5), 95 B" checkout.log # Remove the working directory rm -rf file1.dat file2.dat file3.dat folder1/nested.dat folder2/nested.dat @@ -73,7 +74,7 @@ begin_test "checkout" [ ! -f ../folder2/nested.dat ] # test '.' in current dir rm nested.dat - git lfs checkout . + git lfs checkout . 2>&1 | tee checkout.log [ "$contents" = "$(cat nested.dat)" ] popd diff --git a/tq/meter.go b/tq/meter.go index a42a2cbb..36a6ae2d 100644 --- a/tq/meter.go +++ b/tq/meter.go @@ -5,7 +5,6 @@ import ( "math" "os" "path/filepath" - "strings" "sync" "sync/atomic" "time" @@ -231,12 +230,10 @@ func (m *Meter) skipUpdate() bool { func (m *Meter) str() string { // (Uploading|Downloading) LFS objects: 100% (10/10) 100 MiB | 10 MiB/s - - direction := strings.Title(m.Direction.String()) + "ing" percentage := 100 * float64(m.finishedFiles) / float64(m.estimatedFiles) return fmt.Sprintf("%s LFS objects: %3.f%% (%d/%d), %s | %s", - direction, + m.Direction.Verb(), percentage, m.finishedFiles, m.estimatedFiles, humanize.FormatBytes(clamp(m.currentBytes)), diff --git a/tq/transfer.go b/tq/transfer.go index b6a31ecc..60484e74 100644 --- a/tq/transfer.go +++ b/tq/transfer.go @@ -16,10 +16,27 @@ type Direction int const ( Upload = Direction(iota) Download = Direction(iota) + Checkout = Direction(iota) ) +// Verb returns a string containing the verb form of the receiving action. +func (d Direction) Verb() string { + switch d { + case Checkout: + return "Checking out" + case Download: + return "Downloading" + case Upload: + return "Uploading" + default: + return "" + } +} + func (d Direction) String() string { switch d { + case Checkout: + return "checkout" case Download: return "download" case Upload: