Merge pull request #3055 from git-lfs/checkout-no-confusing-message
commands/checkout: fix inaccurate messaging
This commit is contained in:
commit
f10afe1b9c
@ -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) {
|
||||
|
@ -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
|
||||
|
||||
|
@ -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)),
|
||||
|
@ -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 "<unknown>"
|
||||
}
|
||||
}
|
||||
|
||||
func (d Direction) String() string {
|
||||
switch d {
|
||||
case Checkout:
|
||||
return "checkout"
|
||||
case Download:
|
||||
return "download"
|
||||
case Upload:
|
||||
|
Loading…
Reference in New Issue
Block a user