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

Commit 394d1d0

Browse files
committed
Squash merge with previous work done
Merged with branch: azbshiri/feature/list-out-of-date-dependencies
1 parent d81b4d0 commit 394d1d0

File tree

1 file changed

+61
-1
lines changed

1 file changed

+61
-1
lines changed

cmd/dep/status.go

+61-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package main
66

77
import (
88
"bytes"
9+
"context"
910
"encoding/json"
1011
"flag"
1112
"fmt"
@@ -237,7 +238,7 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
237238
case cmd.missing:
238239
return errors.Errorf("not implemented")
239240
case cmd.old:
240-
return errors.Errorf("not implemented")
241+
cmd.runOld(ctx, args, p, sm)
241242
case cmd.json:
242243
out = &jsonOutput{
243244
w: &buf,
@@ -335,6 +336,65 @@ func (cmd *statusCommand) validateFlags() error {
335336
return nil
336337
}
337338

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+
338398
type rawStatus struct {
339399
ProjectRoot string
340400
Constraint string

0 commit comments

Comments
 (0)