From 2d25bff8b8645b2721a853a18e9e0571caddd8d1 Mon Sep 17 00:00:00 2001 From: Sunny Date: Mon, 11 Sep 2017 15:31:48 +0530 Subject: [PATCH] status: document runStatusAll() result --- cmd/dep/status.go | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/cmd/dep/status.go b/cmd/dep/status.go index 2270013656..5ed824df04 100644 --- a/cmd/dep/status.go +++ b/cmd/dep/status.go @@ -350,22 +350,24 @@ type MissingStatus struct { // errorStatus contains information about error and number of status failures. type errorStatus struct { - err error + err error + // count is for counting errors due to which we don't fail completely, but + // return partial results with missing/unknown data. count int } -func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceManager) (bool, bool, errorStatus) { - var digestMismatch, hasMissingPkgs bool - +func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceManager) (digestMismatch bool, hasMissingPkgs bool, errStatus errorStatus) { if p.Lock == nil { - return digestMismatch, hasMissingPkgs, errorStatus{err: errors.Errorf("no Gopkg.lock found. Run `dep ensure` to generate lock file")} + errStatus.err = errors.Errorf("no Gopkg.lock found. Run `dep ensure` to generate lock file") + return digestMismatch, hasMissingPkgs, errStatus } // While the network churns on ListVersions() requests, statically analyze // code from the current project. ptree, err := pkgtree.ListPackages(p.ResolvedAbsRoot, string(p.ImportRoot)) if err != nil { - return digestMismatch, hasMissingPkgs, errorStatus{err: errors.Wrapf(err, "analysis of local packages failed")} + errStatus.err = errors.Wrapf(err, "analysis of local packages failed") + return digestMismatch, hasMissingPkgs, errStatus } // Set up a solver in order to check the InputHash. @@ -390,7 +392,8 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana s, err := gps.Prepare(params, sm) if err != nil { - return digestMismatch, hasMissingPkgs, errorStatus{err: errors.Wrapf(err, "could not set up solver for input hashing")} + errStatus.err = errors.Wrapf(err, "could not set up solver for input hashing") + return digestMismatch, hasMissingPkgs, errStatus } cm := collectConstraints(ptree, p, sm) @@ -517,12 +520,9 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana // Newline after printing the status progress output logger.Println() - var statusError error - var errorCount int - // List Packages errors. This would happen only for dot output. if len(errListPkgCh) > 0 { - statusError = errFailedListPkg + errStatus.err = errFailedListPkg if ctx.Verbose { for err := range errListPkgCh { ctx.Err.Println(err.Error()) @@ -533,13 +533,15 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana // List Version errors if len(errListVerCh) > 0 { - if statusError == errFailedListPkg { - statusError = errMultipleFailures + if errStatus.err == nil { + errStatus.err = errFailedUpdate } else { - statusError = errFailedUpdate + errStatus.err = errMultipleFailures } - errorCount = len(errListVerCh) + // Count ListVersions error because we get partial results when + // this happens. + errStatus.count = len(errListVerCh) if ctx.Verbose { for err := range errListVerCh { ctx.Err.Println(err.Error()) @@ -563,7 +565,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana out.BasicFooter() - return digestMismatch, hasMissingPkgs, errorStatus{err: statusError, count: errorCount} + return digestMismatch, hasMissingPkgs, errStatus } // Hash digest mismatch may indicate that some deps are no longer