@@ -6,6 +6,7 @@ package main
6
6
7
7
import (
8
8
"bytes"
9
+ "context"
9
10
"encoding/json"
10
11
"flag"
11
12
"fmt"
@@ -237,7 +238,7 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
237
238
case cmd .missing :
238
239
return errors .Errorf ("not implemented" )
239
240
case cmd .old :
240
- return errors . Errorf ( "not implemented" )
241
+ cmd . runOld ( ctx , args , p , sm )
241
242
case cmd .json :
242
243
out = & jsonOutput {
243
244
w : & buf ,
@@ -335,6 +336,65 @@ func (cmd *statusCommand) validateFlags() error {
335
336
return nil
336
337
}
337
338
339
+ // OldStatus contains information about all the out of date packages in a project.
340
+ type OldStatus struct {
341
+ ProjectRoot string
342
+ Constraint gps.Constraint
343
+ Version gps.UnpairedVersion
344
+ Revision gps.Revision
345
+ Latest gps.Version
346
+ }
347
+
348
+ func (cmd * statusCommand ) runOld (ctx * dep.Ctx , args []string , p * dep.Project , sm gps.SourceManager ) error {
349
+ // While the network churns on ListVersions() requests, statically analyze
350
+ // code from the current project.
351
+ ptree , err := p .ParseRootPackageTree ()
352
+ if err != nil {
353
+ return err
354
+ }
355
+
356
+ // Set up a solver in order to check the InputHash.
357
+ params := gps.SolveParameters {
358
+ ProjectAnalyzer : dep.Analyzer {},
359
+ RootDir : p .AbsRoot ,
360
+ RootPackageTree : ptree ,
361
+ Manifest : p .Manifest ,
362
+ // Locks aren't a part of the input hash check, so we can omit it.
363
+ }
364
+
365
+ // Check update for all the projects
366
+ params .ChangeAll = true
367
+
368
+ solver , err := gps .Prepare (params , sm )
369
+ if err != nil {
370
+ return errors .Wrap (err , "fastpath solver prepare" )
371
+ }
372
+
373
+ solution , err := solver .Solve (context .TODO ())
374
+ if err != nil {
375
+ return errors .Wrap (err , "runOld" )
376
+ }
377
+
378
+ var oldLockProjects []gps.LockedProject
379
+ lockProjects := p .Lock .Projects ()
380
+ solutionProjects := solution .Projects ()
381
+
382
+ for i := range solutionProjects {
383
+ spr , _ , _ := gps .VersionComponentStrings (solutionProjects [i ].Version ())
384
+ lpr , _ , _ := gps .VersionComponentStrings (lockProjects [i ].Version ())
385
+
386
+ if spr != lpr {
387
+ oldLockProjects = append (oldLockProjects , lockProjects [i ])
388
+ }
389
+ }
390
+
391
+ for _ , oldLockProject := range oldLockProjects {
392
+ ctx .Out .Println (oldLockProject )
393
+ }
394
+
395
+ return nil
396
+ }
397
+
338
398
type rawStatus struct {
339
399
ProjectRoot string
340
400
Constraint string
0 commit comments