@@ -243,8 +243,6 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
243
243
switch {
244
244
case cmd .missing :
245
245
return errors .Errorf ("not implemented" )
246
- case cmd .old :
247
- cmd .runOld (ctx , args , p , sm )
248
246
case cmd .json :
249
247
out = & jsonOutput {
250
248
w : & buf ,
@@ -275,7 +273,7 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
275
273
return errors .Errorf ("no Gopkg.lock found. Run `dep ensure` to generate lock file" )
276
274
}
277
275
278
- hasMissingPkgs , errCount , err := runStatusAll (ctx , out , p , sm )
276
+ hasMissingPkgs , errCount , err := runStatusAll (ctx , out , p , sm , cmd )
279
277
if err != nil {
280
278
switch err {
281
279
case errFailedUpdate :
@@ -351,56 +349,6 @@ type OldStatus struct {
351
349
Latest gps.Version
352
350
}
353
351
354
- func (cmd * statusCommand ) runOld (ctx * dep.Ctx , args []string , p * dep.Project , sm gps.SourceManager ) error {
355
- // While the network churns on ListVersions() requests, statically analyze
356
- // code from the current project.
357
- ptree , err := p .ParseRootPackageTree ()
358
- if err != nil {
359
- return err
360
- }
361
-
362
- // Set up a solver in order to check the InputHash.
363
- params := gps.SolveParameters {
364
- ProjectAnalyzer : dep.Analyzer {},
365
- RootDir : p .AbsRoot ,
366
- RootPackageTree : ptree ,
367
- Manifest : p .Manifest ,
368
- // Locks aren't a part of the input hash check, so we can omit it.
369
- }
370
-
371
- // Check update for all the projects
372
- params .ChangeAll = true
373
-
374
- solver , err := gps .Prepare (params , sm )
375
- if err != nil {
376
- return errors .Wrap (err , "fastpath solver prepare" )
377
- }
378
-
379
- solution , err := solver .Solve (context .TODO ())
380
- if err != nil {
381
- return errors .Wrap (err , "runOld" )
382
- }
383
-
384
- var oldLockProjects []gps.LockedProject
385
- lockProjects := p .Lock .Projects ()
386
- solutionProjects := solution .Projects ()
387
-
388
- for i := range solutionProjects {
389
- spr , _ , _ := gps .VersionComponentStrings (solutionProjects [i ].Version ())
390
- lpr , _ , _ := gps .VersionComponentStrings (lockProjects [i ].Version ())
391
-
392
- if spr != lpr {
393
- oldLockProjects = append (oldLockProjects , lockProjects [i ])
394
- }
395
- }
396
-
397
- for _ , oldLockProject := range oldLockProjects {
398
- ctx .Out .Println (oldLockProject )
399
- }
400
-
401
- return nil
402
- }
403
-
404
352
type rawStatus struct {
405
353
ProjectRoot string
406
354
Constraint string
@@ -484,7 +432,7 @@ type MissingStatus struct {
484
432
MissingPackages []string
485
433
}
486
434
487
- func runStatusAll (ctx * dep.Ctx , out outputter , p * dep.Project , sm gps.SourceManager ) (hasMissingPkgs bool , errCount int , err error ) {
435
+ func runStatusAll (ctx * dep.Ctx , out outputter , p * dep.Project , sm gps.SourceManager , cmd * statusCommand ) (hasMissingPkgs bool , errCount int , err error ) {
488
436
// While the network churns on ListVersions() requests, statically analyze
489
437
// code from the current project.
490
438
ptree , err := p .ParseRootPackageTree ()
@@ -517,6 +465,17 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
517
465
return false , 0 , errors .Wrapf (err , "could not set up solver for input hashing" )
518
466
}
519
467
468
+ // We only care about solution in the -old flag case
469
+ var solution gps.Solution
470
+ if cmd .old {
471
+ params .ChangeAll = true
472
+ var err error
473
+ solution , err = s .Solve (context .TODO ())
474
+ if err != nil {
475
+ return false , 0 , err
476
+ }
477
+ }
478
+
520
479
// Errors while collecting constraints should not fail the whole status run.
521
480
// It should count the error and tell the user about incomplete results.
522
481
cm , ccerrs := collectConstraints (ctx , p , sm )
@@ -701,7 +660,18 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
701
660
702
661
// Use the collected BasicStatus in outputter.
703
662
for _ , proj := range slp {
704
- if err := out .BasicLine (bsMap [string (proj .Ident ().ProjectRoot )]); err != nil {
663
+ pr := proj .Ident ().ProjectRoot
664
+
665
+ // If -old flag, only display the lines where the solver mismatches
666
+ if cmd .old {
667
+ if matches , err := projUpToDate (proj , solution ); matches {
668
+ continue
669
+ } else if err != nil {
670
+ return false , 0 , err
671
+ }
672
+ }
673
+
674
+ if err := out .BasicLine (bsMap [string (pr )]); err != nil {
705
675
return false , 0 , err
706
676
}
707
677
}
@@ -782,6 +752,20 @@ outer:
782
752
return hasMissingPkgs , 0 , errInputDigestMismatch
783
753
}
784
754
755
+ // projUpToDate returns true if the project p, is at the same revision as what the solution indicates
756
+ func projUpToDate (p gps.LockedProject , s gps.Solution ) (bool , error ) {
757
+ solutionProjects := s .Projects ()
758
+ for i := range solutionProjects {
759
+ if solutionProjects [i ].Ident ().ProjectRoot == p .Ident ().ProjectRoot {
760
+ spr , _ , _ := gps .VersionComponentStrings (solutionProjects [i ].Version ())
761
+ lpr , _ , _ := gps .VersionComponentStrings (p .Version ())
762
+ return spr == lpr , nil
763
+ }
764
+ }
765
+ // If we're here, the solution was missing a project. Should never get here but just incase
766
+ return false , errors .New ("solution missing project information for " + string (p .Ident ().ProjectRoot ))
767
+ }
768
+
785
769
func formatVersion (v gps.Version ) string {
786
770
if v == nil {
787
771
return ""
0 commit comments