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

Commit a4c6879

Browse files
authored
Merge pull request #1238 from darkowlzz/1232-status-lockfile-check
fix(status): check lockfile before runStatusAll()
2 parents b7e513c + 365e4ee commit a4c6879

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

cmd/dep/status.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,11 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
236236
}
237237
}
238238

239+
// Check if the lock file exists.
240+
if p.Lock == nil {
241+
return errors.Errorf("no Gopkg.lock found. Run `dep ensure` to generate lock file")
242+
}
243+
239244
hasMissingPkgs, errCount, err := runStatusAll(ctx, out, p, sm)
240245
if err != nil {
241246
switch err {
@@ -256,8 +261,6 @@ func (cmd *statusCommand) Run(ctx *dep.Ctx, args []string) error {
256261
ctx.Err.Printf("Lock inputs-digest mismatch. This happens when Gopkg.toml is modified.\n" +
257262
"Run `dep ensure` to regenerate the inputs-digest.")
258263
}
259-
default:
260-
ctx.Out.Println("Failed to get status. Rerun with `-v` flag to see details.")
261264
}
262265

263266
return err
@@ -353,10 +356,6 @@ type MissingStatus struct {
353356
}
354357

355358
func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceManager) (hasMissingPkgs bool, errCount int, err error) {
356-
if p.Lock == nil {
357-
return false, 0, errors.Errorf("no Gopkg.lock found. Run `dep ensure` to generate lock file")
358-
}
359-
360359
// While the network churns on ListVersions() requests, statically analyze
361360
// code from the current project.
362361
ptree, err := pkgtree.ListPackages(p.ResolvedAbsRoot, string(p.ImportRoot))

0 commit comments

Comments
 (0)