Skip to content

Commit db4e3b2

Browse files
committed
tq: new progress meter formatting
1 parent c848d52 commit db4e3b2

24 files changed

+83
-91
lines changed

commands/command_fetch.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ func fetchAndReportToChan(allpointers []*lfs.WrappedPointer, filter *filepathfil
325325

326326
func readyAndMissingPointers(allpointers []*lfs.WrappedPointer, filter *filepathfilter.Filter) ([]*lfs.WrappedPointer, []*lfs.WrappedPointer, *tq.Meter) {
327327
logger := tasklog.NewLogger(os.Stdout)
328-
meter := buildProgressMeter(false)
328+
meter := buildProgressMeter(false, tq.Download)
329329
logger.Enqueue(meter)
330330

331331
seen := make(map[string]bool, len(allpointers))

commands/commands.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,11 @@ func determineIncludeExcludePaths(config *config.Configuration, includeArg, excl
430430
return
431431
}
432432

433-
func buildProgressMeter(dryRun bool) *tq.Meter {
433+
func buildProgressMeter(dryRun bool, d tq.Direction) *tq.Meter {
434434
m := tq.NewMeter()
435435
m.Logger = m.LoggerFromEnv(cfg.Os)
436436
m.DryRun = dryRun
437+
m.Direction = d
437438
return m
438439
}
439440

commands/uploader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func newUploadContext(dryRun bool) *uploadContext {
108108
}
109109

110110
ctx.logger = tasklog.NewLogger(sink)
111-
ctx.meter = buildProgressMeter(ctx.DryRun)
111+
ctx.meter = buildProgressMeter(ctx.DryRun, tq.Upload)
112112
ctx.logger.Enqueue(ctx.meter)
113113
ctx.committerName, ctx.committerEmail = cfg.CurrentCommitter()
114114
return ctx

test/test-batch-transfer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ begin_test "batch transfer"
4949

5050
# This pushes to the remote repository set up at the top of the test.
5151
git push origin master 2>&1 | tee push.log
52-
grep "(1 of 1 files)" push.log
52+
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
5353
grep "master -> master" push.log
5454

5555
assert_server_object "$reponame" "$contents_oid"

test/test-chunked-transfer-encoding.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ begin_test "chunked transfer encoding"
4848

4949
# This pushes to the remote repository set up at the top of the test.
5050
git push origin master 2>&1 | tee push.log
51-
grep "(1 of 1 files)" push.log
51+
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
5252
grep "master -> master" push.log
5353

5454
assert_server_object "$reponame" "$contents_oid"

test/test-clone.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ begin_test "clone"
4646
newclonedir="testclone1"
4747
git lfs clone "$GITSERVER/$reponame" "$newclonedir" 2>&1 | tee lfsclone.log
4848
grep "Cloning into" lfsclone.log
49-
grep "Git LFS:" lfsclone.log
49+
grep "Downloading LFS objects:" lfsclone.log
5050
# should be no filter errors
5151
[ ! $(grep "filter" lfsclone.log) ]
5252
[ ! $(grep "error" lfsclone.log) ]
@@ -67,7 +67,7 @@ begin_test "clone"
6767
rm -rf "$reponame"
6868
git lfs clone "$GITSERVER/$reponame" 2>&1 | tee lfsclone.log
6969
grep "Cloning into" lfsclone.log
70-
grep "Git LFS:" lfsclone.log
70+
grep "Downloading LFS objects:" lfsclone.log
7171
# should be no filter errors
7272
[ ! $(grep "filter" lfsclone.log) ]
7373
[ ! $(grep "error" lfsclone.log) ]
@@ -328,7 +328,7 @@ begin_test "clone (with include/exclude args)"
328328

329329
git push origin master 2>&1 | tee push.log
330330
grep "master -> master" push.log
331-
grep "Git LFS: (2 of 2 files)" push.log
331+
grep "Uploading LFS objects: 100% (2/2), 2 B" push.log
332332

333333
cd "$TRASHDIR"
334334

@@ -392,7 +392,7 @@ begin_test "clone (with .lfsconfig)"
392392

393393
git push origin master 2>&1 | tee push.log
394394
grep "master -> master" push.log
395-
grep "Git LFS: (2 of 2 files)" push.log
395+
grep "Uploading LFS objects: 100% (2/2), 2 B" push.log
396396

397397
pushd "$TRASHDIR"
398398

@@ -482,7 +482,7 @@ begin_test "clone (without clean filter)"
482482

483483
git push origin master 2>&1 | tee push.log
484484
grep "master -> master" push.log
485-
grep "Git LFS: (1 of 1 files)" push.log
485+
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
486486

487487
cd "$TRASHDIR"
488488

@@ -613,7 +613,7 @@ begin_test "clone in current directory"
613613
mkdir "$reponame-clone"
614614
cd "$reponame-clone"
615615

616-
git lfs clone $GITSERVER/$reponame "." 2>&1 | grep "Git LFS"
616+
git lfs clone $GITSERVER/$reponame "." 2>&1 | grep "Downloading LFS objects: 100% (1/1), 8 B"
617617

618618
assert_local_object "$contents_oid" 8
619619
assert_hooks "$(dot_git_dir)"

test/test-credentials.sh

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ begin_test "credentials without useHttpPath, with bad path password"
5151
git commit -m "add a.dat"
5252

5353
GIT_TRACE=1 git push origin without-path 2>&1 | tee push.log
54-
grep "(1 of 1 files)" push.log
54+
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
5555

5656
echo "approvals:"
5757
[ "1" -eq "$(cat push.log | grep "creds: git credential approve" | wc -l)" ]
@@ -88,7 +88,7 @@ begin_test "credentials with url-specific useHttpPath, with bad path password"
8888
git commit -m "add a.dat"
8989

9090
GIT_TRACE=1 git push origin without-path 2>&1 | tee push.log
91-
grep "(1 of 1 files)" push.log
91+
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
9292

9393
echo "approvals:"
9494
[ "1" -eq "$(cat push.log | grep "creds: git credential approve" | wc -l)" ]
@@ -121,7 +121,7 @@ begin_test "credentials with useHttpPath, with wrong password"
121121
git commit -m "add a.dat"
122122

123123
GIT_TRACE=1 git push origin with-path-wrong-pass 2>&1 | tee push.log
124-
[ "0" = "$(grep -c "(1 of 1 files)" push.log)" ]
124+
[ "0" = "$(grep -c "Uploading LFS objects: 100% (1/1), 0 B" push.log)" ]
125125
echo "approvals:"
126126
[ "0" -eq "$(cat push.log | grep "creds: git credential approve" | wc -l)" ]
127127
echo "fills:"
@@ -155,7 +155,7 @@ begin_test "credentials with useHttpPath, with correct password"
155155
git commit -m "add b.dat"
156156

157157
GIT_TRACE=1 git push origin with-path-correct-pass 2>&1 | tee push.log
158-
grep "(1 of 1 files)" push.log
158+
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
159159
echo "approvals:"
160160
[ "1" -eq "$(cat push.log | grep "creds: git credential approve" | wc -l)" ]
161161
echo "fills:"
@@ -253,7 +253,7 @@ begin_test "credentials from netrc"
253253
git commit -m "add a.dat"
254254

255255
GIT_TRACE=1 git lfs push netrc master 2>&1 | tee push.log
256-
grep "(1 of 1 files)" push.log
256+
grep "Uploading LFS objects: 100% (1/1), 7 B" push.log
257257
echo "any git credential calls:"
258258
[ "0" -eq "$(cat push.log | grep "git credential" | wc -l)" ]
259259
)
@@ -286,7 +286,7 @@ begin_test "credentials from netrc with bad password"
286286
git commit -m "add a.dat"
287287

288288
git push netrc master 2>&1 | tee push.log
289-
[ "0" = "$(grep -c "(1 of 1 files)" push.log)" ]
289+
[ "0" = "$(grep -c "Uploading LFS objects: 100% (1/1), 7 B" push.log)" ]
290290
)
291291
end_test
292292

@@ -306,28 +306,28 @@ begin_test "credentials from lfs.url"
306306
echo "bad push"
307307
git lfs env
308308
git lfs push origin master 2>&1 | tee push.log
309-
grep "(0 of 1 files)" push.log
309+
grep "Uploading LFS objects: 0% (0/1), 0 B" push.log
310310

311311
echo "good push"
312312
gitserverhost=$(echo "$GITSERVER" | cut -d'/' -f3)
313313
git config lfs.url http://requirecreds:pass@$gitserverhost/$reponame.git/info/lfs
314314
git lfs env
315315
git lfs push origin master 2>&1 | tee push.log
316-
grep "(1 of 1 files)" push.log
316+
grep "Uploading LFS objects: 0% (0/1), 0 B" push.log
317317

318318
echo "bad fetch"
319319
rm -rf .git/lfs/objects
320320
git config lfs.url http://$gitserverhost/$reponame.git/info/lfs
321321
git lfs env
322322
git lfs fetch --all 2>&1 | tee fetch.log
323-
grep "(0 of 1 files)" fetch.log
323+
grep "Downloading LFS objects: 0% (0/1), 0 B" fetch.log
324324

325325
echo "good fetch"
326326
rm -rf .git/lfs/objects
327327
git config lfs.url http://requirecreds:pass@$gitserverhost/$reponame.git/info/lfs
328328
git lfs env
329329
git lfs fetch --all 2>&1 | tee fetch.log
330-
grep "(1 of 1 files)" fetch.log
330+
grep "Downloading LFS objects: 100% (1/1), 7 B" fetch.log
331331
)
332332
end_test
333333

@@ -347,27 +347,28 @@ begin_test "credentials from remote.origin.url"
347347
echo "bad push"
348348
git lfs env
349349
git lfs push origin master 2>&1 | tee push.log
350-
grep "(0 of 1 files)" push.log
350+
grep "Uploading LFS objects: 0% (0/1), 0 B" push.log
351351

352352
echo "good push"
353353
gitserverhost=$(echo "$GITSERVER" | cut -d'/' -f3)
354354
git config remote.origin.url http://requirecreds:pass@$gitserverhost/$reponame.git
355355
git lfs env
356356
git lfs push origin master 2>&1 | tee push.log
357-
grep "(1 of 1 files)" push.log
357+
grep "Uploading LFS objects: 100% (1/1), 7 B" push.log
358358

359359
echo "bad fetch"
360360
rm -rf .git/lfs/objects
361361
git config remote.origin.url http://$gitserverhost/$reponame.git
362362
git lfs env
363363
git lfs fetch --all 2>&1 | tee fetch.log
364-
grep "(0 of 1 files)" fetch.log
364+
# Missing authentication causes `git lfs fetch` to fail before the progress
365+
# meter is printed to the TTY.
365366

366367
echo "good fetch"
367368
rm -rf .git/lfs/objects
368369
git config remote.origin.url http://requirecreds:pass@$gitserverhost/$reponame.git
369370
git lfs env
370371
git lfs fetch --all 2>&1 | tee fetch.log
371-
grep "(1 of 1 files)" fetch.log
372+
grep "Downloading LFS objects: 100% (1/1), 7 B" fetch.log
372373
)
373374
end_test

test/test-custom-transfers.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,15 @@ begin_test "custom-transfer-upload-download"
9494

9595
grep "xfer: started custom adapter process" pushcustom.log
9696
grep "xfer\[lfstest-customadapter\]:" pushcustom.log
97-
grep "12 of 12 files" pushcustom.log
97+
grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
9898

9999
rm -rf .git/lfs/objects
100100
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetchcustom.log
101101
[ ${PIPESTATUS[0]} = "0" ]
102102

103103
grep "xfer: started custom adapter process" fetchcustom.log
104104
grep "xfer\[lfstest-customadapter\]:" fetchcustom.log
105-
grep "12 of 12 files" fetchcustom.log
105+
grep "Downloading LFS objects: 100% (12/12)" fetchcustom.log
106106

107107
grep "Terminating test custom adapter gracefully" fetchcustom.log
108108

@@ -176,15 +176,15 @@ begin_test "custom-transfer-standalone"
176176

177177
grep "xfer: started custom adapter process" pushcustom.log
178178
grep "xfer\[lfstest-standalonecustomadapter\]:" pushcustom.log
179-
grep "12 of 12 files" pushcustom.log
179+
grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
180180

181181
rm -rf .git/lfs/objects
182182
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetchcustom.log
183183
[ ${PIPESTATUS[0]} = "0" ]
184184

185185
grep "xfer: started custom adapter process" fetchcustom.log
186186
grep "xfer\[lfstest-standalonecustomadapter\]:" fetchcustom.log
187-
grep "12 of 12 files" fetchcustom.log
187+
grep "Downloading LFS objects: 100% (12/12)" fetchcustom.log
188188

189189
grep "Terminating test custom adapter gracefully" fetchcustom.log
190190

@@ -262,15 +262,15 @@ begin_test "custom-transfer-standalone-urlmatch"
262262

263263
grep "xfer: started custom adapter process" pushcustom.log
264264
grep "xfer\[lfstest-standalonecustomadapter\]:" pushcustom.log
265-
grep "12 of 12 files" pushcustom.log
265+
grep "Uploading LFS objects: 100% (12/12)" pushcustom.log
266266

267267
rm -rf .git/lfs/objects
268268
GIT_TRACE=1 GIT_TRANSFER_TRACE=1 git lfs fetch --all 2>&1 | tee fetchcustom.log
269269
[ ${PIPESTATUS[0]} = "0" ]
270270

271271
grep "xfer: started custom adapter process" fetchcustom.log
272272
grep "xfer\[lfstest-standalonecustomadapter\]:" fetchcustom.log
273-
grep "12 of 12 files" fetchcustom.log
273+
grep "Downloading LFS objects: 100% (12/12)" fetchcustom.log
274274

275275
grep "Terminating test custom adapter gracefully" fetchcustom.log
276276

test/test-duplicate-oids.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ begin_test "multiple revs with same OID get pushed once"
4343
# Delay the push until here, so the server doesn't have a copy of the OID that
4444
# we're trying to push.
4545
git push origin master 2>&1 | tee push.log
46-
grep "Git LFS: (1 of 1 files)" push.log
46+
grep "Uploading LFS objects: 100% (1/1), 8 B" push.log
4747

4848
assert_server_object "$reponame" "$contents_oid"
4949
)

test/test-fetch-include.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ begin_test "fetch: setup for include test"
3636
grep "create mode 100644 big/big3.big" commit.log
3737

3838
git push origin master | tee push.log
39-
grep "2 of 2 files" push.log
39+
grep "Uploading LFS objects: 100% (2/2), 18 B" push.log
4040

4141
assert_server_object "$reponame" "$contents_oid"
4242
)

test/test-fetch-paths.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ begin_test "init fetch unclean paths"
3333
refute_server_object "$contents_oid"
3434

3535
git push origin master 2>&1 | tee push.log
36-
grep "(1 of 1 files)" push.log
36+
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
3737
grep "master -> master" push.log
3838

3939
assert_server_object "$reponame" "$contents_oid"

test/test-fetch.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ begin_test "init for fetch tests"
3636
refute_server_object "$reponame" "$contents_oid"
3737

3838
git push origin master 2>&1 | tee push.log
39-
grep "(1 of 1 files)" push.log
39+
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
4040
grep "master -> master" push.log
4141

4242
assert_server_object "$reponame" "$contents_oid"
@@ -62,7 +62,7 @@ begin_test "fetch"
6262
cd clone
6363
rm -rf .git/lfs/objects
6464

65-
git lfs fetch 2>&1 | grep "(1 of 1 files)"
65+
git lfs fetch 2>&1 | grep "Downloading LFS objects: 100% (1/1), 1 B"
6666
assert_local_object "$contents_oid" 1
6767
)
6868
end_test
@@ -73,7 +73,7 @@ begin_test "fetch with remote"
7373
cd clone
7474
rm -rf .git/lfs/objects
7575

76-
git lfs fetch origin 2>&1 | grep "(1 of 1 files)"
76+
git lfs fetch origin 2>&1 | grep "Downloading LFS objects: 100% (1/1), 1 B"
7777
assert_local_object "$contents_oid" 1
7878
refute_local_object "$b_oid" 1
7979
)
@@ -416,7 +416,7 @@ begin_test "fetch with no origin remote"
416416
refute_server_object "$reponame" "$contents_oid"
417417

418418
git push origin master 2>&1 | tee push.log
419-
grep "(1 of 1 files)" push.log
419+
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
420420
grep "master -> master" push.log
421421

422422

test/test-happy-path.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ begin_test "happy path"
4848

4949
# This pushes to the remote repository set up at the top of the test.
5050
git push origin master 2>&1 | tee push.log
51-
grep "(1 of 1 files)" push.log
51+
grep "Uploading LFS objects: 100% (1/1), 1 B" push.log
5252
grep "master -> master" push.log
5353

5454
assert_server_object "$reponame" "$contents_oid"

0 commit comments

Comments
 (0)