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

Commit

Permalink
status: document runStatusAll() result
Browse files Browse the repository at this point in the history
  • Loading branch information
darkowlzz committed Sep 12, 2017
1 parent 2bdbfb7 commit 4e08f0a
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions cmd/dep/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,22 +354,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.
Expand All @@ -394,7 +396,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)
Expand Down Expand Up @@ -521,12 +524,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())
Expand All @@ -537,13 +537,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())
Expand All @@ -567,7 +569,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
Expand Down

0 comments on commit 4e08f0a

Please sign in to comment.