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

Commit

Permalink
Merge pull request #1238 from darkowlzz/1232-status-lockfile-check
Browse files Browse the repository at this point in the history
fix(status): check lockfile before runStatusAll()
  • Loading branch information
sdboyer committed Oct 7, 2017
2 parents b7e513c + 365e4ee commit a4c6879
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,11 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
}
}

// Check if the lock file exists.
if p.Lock == nil {
return errors.Errorf("no Gopkg.lock found. Run `dep ensure` to generate lock file")
}

hasMissingPkgs, errCount, err := runStatusAll(ctx, out, p, sm)
if err != nil {
switch err {
Expand All @@ -256,8 +261,6 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
ctx.Err.Printf("Lock inputs-digest mismatch. This happens when Gopkg.toml is modified.\n" +
"Run `dep ensure` to regenerate the inputs-digest.")
}
default:
ctx.Out.Println("Failed to get status. Rerun with `-v` flag to see details.")
}

return err
Expand Down Expand Up @@ -353,10 +356,6 @@ type MissingStatus struct {
}

func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceManager) (hasMissingPkgs bool, errCount int, err error) {
if p.Lock == nil {
return false, 0, errors.Errorf("no Gopkg.lock found. Run `dep ensure` to generate lock file")
}

// While the network churns on ListVersions() requests, statically analyze
// code from the current project.
ptree, err := pkgtree.ListPackages(p.ResolvedAbsRoot, string(p.ImportRoot))
Expand Down

0 comments on commit a4c6879

Please sign in to comment.