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

Commit 2d25bff

Browse files
committed
status: document runStatusAll() result
1 parent bdc7710 commit 2d25bff

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

cmd/dep/status.go

+18-16
Original file line numberDiff line numberDiff line change
@@ -350,22 +350,24 @@ type MissingStatus struct {
350350

351351
// errorStatus contains information about error and number of status failures.
352352
type errorStatus struct {
353-
err error
353+
err error
354+
// count is for counting errors due to which we don't fail completely, but
355+
// return partial results with missing/unknown data.
354356
count int
355357
}
356358

357-
func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceManager) (bool, bool, errorStatus) {
358-
var digestMismatch, hasMissingPkgs bool
359-
359+
func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceManager) (digestMismatch bool, hasMissingPkgs bool, errStatus errorStatus) {
360360
if p.Lock == nil {
361-
return digestMismatch, hasMissingPkgs, errorStatus{err: errors.Errorf("no Gopkg.lock found. Run `dep ensure` to generate lock file")}
361+
errStatus.err = errors.Errorf("no Gopkg.lock found. Run `dep ensure` to generate lock file")
362+
return digestMismatch, hasMissingPkgs, errStatus
362363
}
363364

364365
// While the network churns on ListVersions() requests, statically analyze
365366
// code from the current project.
366367
ptree, err := pkgtree.ListPackages(p.ResolvedAbsRoot, string(p.ImportRoot))
367368
if err != nil {
368-
return digestMismatch, hasMissingPkgs, errorStatus{err: errors.Wrapf(err, "analysis of local packages failed")}
369+
errStatus.err = errors.Wrapf(err, "analysis of local packages failed")
370+
return digestMismatch, hasMissingPkgs, errStatus
369371
}
370372

371373
// 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
390392

391393
s, err := gps.Prepare(params, sm)
392394
if err != nil {
393-
return digestMismatch, hasMissingPkgs, errorStatus{err: errors.Wrapf(err, "could not set up solver for input hashing")}
395+
errStatus.err = errors.Wrapf(err, "could not set up solver for input hashing")
396+
return digestMismatch, hasMissingPkgs, errStatus
394397
}
395398

396399
cm := collectConstraints(ptree, p, sm)
@@ -517,12 +520,9 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
517520
// Newline after printing the status progress output
518521
logger.Println()
519522

520-
var statusError error
521-
var errorCount int
522-
523523
// List Packages errors. This would happen only for dot output.
524524
if len(errListPkgCh) > 0 {
525-
statusError = errFailedListPkg
525+
errStatus.err = errFailedListPkg
526526
if ctx.Verbose {
527527
for err := range errListPkgCh {
528528
ctx.Err.Println(err.Error())
@@ -533,13 +533,15 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
533533

534534
// List Version errors
535535
if len(errListVerCh) > 0 {
536-
if statusError == errFailedListPkg {
537-
statusError = errMultipleFailures
536+
if errStatus.err == nil {
537+
errStatus.err = errFailedUpdate
538538
} else {
539-
statusError = errFailedUpdate
539+
errStatus.err = errMultipleFailures
540540
}
541541

542-
errorCount = len(errListVerCh)
542+
// Count ListVersions error because we get partial results when
543+
// this happens.
544+
errStatus.count = len(errListVerCh)
543545
if ctx.Verbose {
544546
for err := range errListVerCh {
545547
ctx.Err.Println(err.Error())
@@ -563,7 +565,7 @@ func runStatusAll(ctx *dep.Ctx, out outputter, p *dep.Project, sm gps.SourceMana
563565

564566
out.BasicFooter()
565567

566-
return digestMismatch, hasMissingPkgs, errorStatus{err: statusError, count: errorCount}
568+
return digestMismatch, hasMissingPkgs, errStatus
567569
}
568570

569571
// Hash digest mismatch may indicate that some deps are no longer

0 commit comments

Comments
 (0)