@@ -231,22 +231,22 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
231
231
}
232
232
}
233
233
234
- digestMismatch , hasMissingPkgs , errStatus := runStatusAll (ctx , out , p , sm )
235
- if errStatus . err != nil {
234
+ digestMismatch , hasMissingPkgs , errCount , errStatus := runStatusAll (ctx , out , p , sm )
235
+ if errStatus != nil {
236
236
// If it's only update errors
237
- if errStatus . err == errFailedUpdate {
237
+ if errStatus == errFailedUpdate {
238
238
// Print the results with unknown data
239
239
ctx .Out .Println (buf .String ())
240
240
241
241
// Print the help when in non-verbose mode
242
242
if ! ctx .Verbose {
243
- ctx .Out .Printf ("The status of %d projects are unknown due to errors. Rerun with `-v` flag to see details.\n " , errStatus . count )
243
+ ctx .Out .Printf ("The status of %d projects are unknown due to errors. Rerun with `-v` flag to see details.\n " , errCount )
244
244
}
245
245
} else {
246
246
// List package failure or multiple failures
247
247
ctx .Out .Println ("Failed to get status. Rerun with `-v` flag to see details." )
248
248
}
249
- return errStatus . err
249
+ return errStatus
250
250
}
251
251
252
252
if digestMismatch {
@@ -348,26 +348,16 @@ type MissingStatus struct {
348
348
MissingPackages []string
349
349
}
350
350
351
- // errorStatus contains information about error and number of status failures.
352
- type errorStatus struct {
353
- err error
354
- // count is for counting errors due to which we don't fail completely, but
355
- // return partial results with missing/unknown data.
356
- count int
357
- }
358
-
359
- func runStatusAll (ctx * dep.Ctx , out outputter , p * dep.Project , sm gps.SourceManager ) (digestMismatch bool , hasMissingPkgs bool , errStatus errorStatus ) {
351
+ func runStatusAll (ctx * dep.Ctx , out outputter , p * dep.Project , sm gps.SourceManager ) (digestMismatch bool , hasMissingPkgs bool , errCount int , errStatus error ) {
360
352
if p .Lock == nil {
361
- errStatus .err = errors .Errorf ("no Gopkg.lock found. Run `dep ensure` to generate lock file" )
362
- return digestMismatch , hasMissingPkgs , errStatus
353
+ return false , false , 0 , errors .Errorf ("no Gopkg.lock found. Run `dep ensure` to generate lock file" )
363
354
}
364
355
365
356
// While the network churns on ListVersions() requests, statically analyze
366
357
// code from the current project.
367
358
ptree , err := pkgtree .ListPackages (p .ResolvedAbsRoot , string (p .ImportRoot ))
368
359
if err != nil {
369
- errStatus .err = errors .Wrapf (err , "analysis of local packages failed" )
370
- return digestMismatch , hasMissingPkgs , errStatus
360
+ return false , false , 0 , errors .Wrapf (err , "analysis of local packages failed" )
371
361
}
372
362
373
363
// Set up a solver in order to check the InputHash.
@@ -387,13 +377,12 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
387
377
}
388
378
389
379
if err := ctx .ValidateParams (sm , params ); err != nil {
390
- return digestMismatch , hasMissingPkgs , errorStatus { err : err }
380
+ return false , false , 0 , err
391
381
}
392
382
393
383
s , err := gps .Prepare (params , sm )
394
384
if err != nil {
395
- errStatus .err = errors .Wrapf (err , "could not set up solver for input hashing" )
396
- return digestMismatch , hasMissingPkgs , errStatus
385
+ return false , false , 0 , errors .Wrapf (err , "could not set up solver for input hashing" )
397
386
}
398
387
399
388
cm := collectConstraints (ptree , p , sm )
@@ -522,7 +511,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
522
511
523
512
// List Packages errors. This would happen only for dot output.
524
513
if len (errListPkgCh ) > 0 {
525
- errStatus . err = errFailedListPkg
514
+ errStatus = errFailedListPkg
526
515
if ctx .Verbose {
527
516
for err := range errListPkgCh {
528
517
ctx .Err .Println (err .Error ())
@@ -533,15 +522,15 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
533
522
534
523
// List Version errors
535
524
if len (errListVerCh ) > 0 {
536
- if errStatus . err == nil {
537
- errStatus . err = errFailedUpdate
525
+ if errStatus == nil {
526
+ errStatus = errFailedUpdate
538
527
} else {
539
- errStatus . err = errMultipleFailures
528
+ errStatus = errMultipleFailures
540
529
}
541
530
542
531
// Count ListVersions error because we get partial results when
543
532
// this happens.
544
- errStatus . count = len (errListVerCh )
533
+ errCount = len (errListVerCh )
545
534
if ctx .Verbose {
546
535
for err := range errListVerCh {
547
536
ctx .Err .Println (err .Error ())
@@ -565,7 +554,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
565
554
566
555
out .BasicFooter ()
567
556
568
- return digestMismatch , hasMissingPkgs , errStatus
557
+ return false , false , errCount , errStatus
569
558
}
570
559
571
560
// Hash digest mismatch may indicate that some deps are no longer
@@ -607,7 +596,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
607
596
ctx .Err .Printf ("\t %s: %s\n " , fail .ex , fail .err .Error ())
608
597
}
609
598
610
- return digestMismatch , hasMissingPkgs , errorStatus { err : errors .New ("address issues with undeducible import paths to get more status information" )}
599
+ return digestMismatch , hasMissingPkgs , 0 , errors .New ("address issues with undeducible import paths to get more status information" )
611
600
}
612
601
613
602
out .MissingHeader ()
@@ -627,7 +616,7 @@ outer:
627
616
}
628
617
out .MissingFooter ()
629
618
630
- return digestMismatch , hasMissingPkgs , errorStatus {}
619
+ return digestMismatch , hasMissingPkgs , 0 , nil
631
620
}
632
621
633
622
func formatVersion (v gps.Version ) string {
0 commit comments