Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 17bb4d6

Browse files
committed
status: cleanup
1 parent 88230aa commit 17bb4d6

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

cmd/dep/status.go

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ Status returns exit code zero if all dependencies are in a "good state".
4444
`
4545

4646
const (
47-
shortRev = iota
48-
longRev = iota
47+
shortRev uint8 = iota
48+
longRev
4949
)
5050

5151
var (
@@ -317,7 +317,7 @@ func (bs *BasicStatus) getConsolidatedVersion() string {
317317
return version
318318
}
319319

320-
func (bs *BasicStatus) getConsolidatedLatest(revSize int) string {
320+
func (bs *BasicStatus) getConsolidatedLatest(revSize uint8) string {
321321
latest := ""
322322
if bs.Latest != nil {
323323
switch revSize {
@@ -408,10 +408,10 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
408408

409409
logger.Println("Checking upstream projects:")
410410

411-
// BasicStatus channel to collect all the BasicStatus
411+
// BasicStatus channel to collect all the BasicStatus.
412412
bsCh := make(chan *BasicStatus, len(slp))
413413

414-
// Error channels to collect different errors
414+
// Error channels to collect different errors.
415415
errListPkgCh := make(chan error, len(slp))
416416
errListVerCh := make(chan error, len(slp))
417417

@@ -422,15 +422,13 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
422422
logger.Printf("(%d/%d) %s\n", i+1, len(slp), proj.Ident().ProjectRoot)
423423

424424
go func(proj gps.LockedProject) {
425-
defer wg.Done()
426-
427425
bs := BasicStatus{
428426
ProjectRoot: string(proj.Ident().ProjectRoot),
429427
PackageCount: len(proj.Packages()),
430428
}
431429

432430
// Get children only for specific outputers
433-
// in order to avoid slower status process
431+
// in order to avoid slower status process.
434432
switch out.(type) {
435433
case *dotOutput:
436434
ptr, err := sm.ListPackages(proj.Ident(), proj.Version())
@@ -444,7 +442,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
444442
bs.Children = prm.FlattenFn(paths.IsStandardImportPath)
445443
}
446444

447-
// Split apart the version from the lock into its constituent parts
445+
// Split apart the version from the lock into its constituent parts.
448446
switch tv := proj.Version().(type) {
449447
case gps.UnpairedVersion:
450448
bs.Version = tv
@@ -494,14 +492,15 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
494492
}
495493
} else {
496494
// Failed to fetch version list (could happen due to
497-
// network issue)
495+
// network issue).
498496
bs.hasError = true
499497
errListVerCh <- err
500498
}
501499
}
502500

503501
bsCh <- &bs
504502

503+
wg.Done()
505504
}(proj)
506505
}
507506

@@ -510,7 +509,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
510509
close(errListPkgCh)
511510
close(errListVerCh)
512511

513-
// Newline after printing the status progress output
512+
// Newline after printing the status progress output.
514513
logger.Println()
515514

516515
// List Packages errors. This would happen only for dot output.
@@ -524,7 +523,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
524523
}
525524
}
526525

527-
// List Version errors
526+
// List Version errors.
528527
if len(errListVerCh) > 0 {
529528
if err == nil {
530529
err = errFailedUpdate
@@ -551,7 +550,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
551550
bsMap[bs.ProjectRoot] = bs
552551
}
553552

554-
// Use the collected BasicStatus in outputter
553+
// Use the collected BasicStatus in outputter.
555554
for _, proj := range slp {
556555
out.BasicLine(bsMap[string(proj.Ident().ProjectRoot)])
557556
}

cmd/dep/status_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ func TestBasicStatusGetConsolidatedLatest(t *testing.T) {
235235
testCases := []struct {
236236
name string
237237
basicStatus BasicStatus
238-
revSize int
238+
revSize uint8
239239
wantLatest string
240240
}{
241241
{

0 commit comments

Comments
 (0)