@@ -235,22 +235,22 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
235
235
}
236
236
}
237
237
238
- digestMismatch , hasMissingPkgs , errStatus := runStatusAll (ctx , out , p , sm )
239
- if errStatus . err != nil {
238
+ digestMismatch , hasMissingPkgs , errCount , err := runStatusAll (ctx , out , p , sm )
239
+ if err != nil {
240
240
// If it's only update errors
241
- if errStatus . err == errFailedUpdate {
241
+ if err == errFailedUpdate {
242
242
// Print the results with unknown data
243
243
ctx .Out .Println (buf .String ())
244
244
245
245
// Print the help when in non-verbose mode
246
246
if ! ctx .Verbose {
247
- ctx .Out .Printf ("The status of %d projects are unknown due to errors. Rerun with `-v` flag to see details.\n " , errStatus . count )
247
+ ctx .Out .Printf ("The status of %d projects are unknown due to errors. Rerun with `-v` flag to see details.\n " , errCount )
248
248
}
249
249
} else {
250
250
// List package failure or multiple failures
251
251
ctx .Out .Println ("Failed to get status. Rerun with `-v` flag to see details." )
252
252
}
253
- return errStatus . err
253
+ return err
254
254
}
255
255
256
256
if digestMismatch {
@@ -352,26 +352,16 @@ type MissingStatus struct {
352
352
MissingPackages []string
353
353
}
354
354
355
- // errorStatus contains information about error and number of status failures.
356
- type errorStatus struct {
357
- err error
358
- // count is for counting errors due to which we don't fail completely, but
359
- // return partial results with missing/unknown data.
360
- count int
361
- }
362
-
363
- func runStatusAll (ctx * dep.Ctx , out outputter , p * dep.Project , sm gps.SourceManager ) (digestMismatch bool , hasMissingPkgs bool , errStatus errorStatus ) {
355
+ func runStatusAll (ctx * dep.Ctx , out outputter , p * dep.Project , sm gps.SourceManager ) (digestMismatch bool , hasMissingPkgs bool , errCount int , err error ) {
364
356
if p .Lock == nil {
365
- errStatus .err = errors .Errorf ("no Gopkg.lock found. Run `dep ensure` to generate lock file" )
366
- return digestMismatch , hasMissingPkgs , errStatus
357
+ return false , false , 0 , errors .Errorf ("no Gopkg.lock found. Run `dep ensure` to generate lock file" )
367
358
}
368
359
369
360
// While the network churns on ListVersions() requests, statically analyze
370
361
// code from the current project.
371
362
ptree , err := pkgtree .ListPackages (p .ResolvedAbsRoot , string (p .ImportRoot ))
372
363
if err != nil {
373
- errStatus .err = errors .Wrapf (err , "analysis of local packages failed" )
374
- return digestMismatch , hasMissingPkgs , errStatus
364
+ return false , false , 0 , errors .Wrapf (err , "analysis of local packages failed" )
375
365
}
376
366
377
367
// Set up a solver in order to check the InputHash.
@@ -391,13 +381,12 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
391
381
}
392
382
393
383
if err := ctx .ValidateParams (sm , params ); err != nil {
394
- return digestMismatch , hasMissingPkgs , errorStatus { err : err }
384
+ return false , false , 0 , err
395
385
}
396
386
397
387
s , err := gps .Prepare (params , sm )
398
388
if err != nil {
399
- errStatus .err = errors .Wrapf (err , "could not set up solver for input hashing" )
400
- return digestMismatch , hasMissingPkgs , errStatus
389
+ return false , false , 0 , errors .Wrapf (err , "could not set up solver for input hashing" )
401
390
}
402
391
403
392
cm := collectConstraints (ptree , p , sm )
@@ -526,7 +515,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
526
515
527
516
// List Packages errors. This would happen only for dot output.
528
517
if len (errListPkgCh ) > 0 {
529
- errStatus . err = errFailedListPkg
518
+ err = errFailedListPkg
530
519
if ctx .Verbose {
531
520
for err := range errListPkgCh {
532
521
ctx .Err .Println (err .Error ())
@@ -537,15 +526,15 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
537
526
538
527
// List Version errors
539
528
if len (errListVerCh ) > 0 {
540
- if errStatus . err == nil {
541
- errStatus . err = errFailedUpdate
529
+ if err == nil {
530
+ err = errFailedUpdate
542
531
} else {
543
- errStatus . err = errMultipleFailures
532
+ err = errMultipleFailures
544
533
}
545
534
546
535
// Count ListVersions error because we get partial results when
547
536
// this happens.
548
- errStatus . count = len (errListVerCh )
537
+ errCount = len (errListVerCh )
549
538
if ctx .Verbose {
550
539
for err := range errListVerCh {
551
540
ctx .Err .Println (err .Error ())
@@ -569,7 +558,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
569
558
570
559
out .BasicFooter ()
571
560
572
- return digestMismatch , hasMissingPkgs , errStatus
561
+ return false , false , errCount , err
573
562
}
574
563
575
564
// Hash digest mismatch may indicate that some deps are no longer
@@ -578,7 +567,6 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
578
567
//
579
568
// It's possible for digests to not match, but still have a correct
580
569
// lock.
581
- digestMismatch = true
582
570
rm , _ := ptree .ToReachMap (true , true , false , nil )
583
571
584
572
external := rm .FlattenFn (paths .IsStandardImportPath )
@@ -611,7 +599,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
611
599
ctx .Err .Printf ("\t %s: %s\n " , fail .ex , fail .err .Error ())
612
600
}
613
601
614
- return digestMismatch , hasMissingPkgs , errorStatus { err : errors .New ("address issues with undeducible import paths to get more status information" )}
602
+ return true , false , 0 , errors .New ("address issues with undeducible import paths to get more status information" )
615
603
}
616
604
617
605
out .MissingHeader ()
@@ -631,7 +619,7 @@ outer:
631
619
}
632
620
out .MissingFooter ()
633
621
634
- return digestMismatch , hasMissingPkgs , errorStatus {}
622
+ return true , hasMissingPkgs , 0 , nil
635
623
}
636
624
637
625
func formatVersion (v gps.Version ) string {
0 commit comments