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

Commit

Permalink
-s
Browse files Browse the repository at this point in the history
Signed-off-by: Ibrahim AshShohail <ibra.sho@gmail.com>
  • Loading branch information
ibrasho committed Jun 1, 2017
1 parent 1c168c0 commit bbde9bb
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,18 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {

solver, err := gps.Prepare(params, sm)
if err != nil {
if deduceErrs, ok := err.(gps.DeductionFailureErrs); ok {
ctx.Loggers.Err.Println("The following errors occurred while deducing packages:")
for ip, error := range deduceErrs {
ctx.Loggers.Err.Printf(" * \"%s\": %s", ip, error)
}
ctx.Loggers.Err.Println()

return errors.New("could not deduce packages to ensure constraints")
}
return errors.Wrap(err, "ensure Prepare")
}

solution, err := solver.Solve()
if err != nil {
handleAllTheFailuresOfTheWorld(err)
Expand Down
7 changes: 7 additions & 0 deletions internal/gps/solve_failures.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,13 @@ func (e badOptsFailure) Error() string {
return string(e)
}

// DeductionFailureErrs maps package import path to errors occurring during deduction.
type DeductionFailureErrs map[string]error

func (e DeductionFailureErrs) Error() string {
return fmt.Sprintf("%v", e)
}

type sourceMismatchFailure struct {
// The ProjectRoot over which there is disagreement about where it should be
// sourced from
Expand Down
23 changes: 23 additions & 0 deletions internal/gps/solver.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"log"
"sort"
"strings"
"sync"

"github.com/armon/go-radix"
"github.com/golang/dep/internal/gps/paths"
Expand Down Expand Up @@ -289,6 +290,28 @@ func Prepare(params SolveParameters, sm SourceManager) (Solver, error) {
rd: rd,
}

var deducePkgsGroup sync.WaitGroup
deductionErrs := make(DeductionFailureErrs)

checkPkg := func(ip string, sm SourceManager) {
_, err := sm.DeduceProjectRoot(ip)
if err != nil {
deductionErrs[ip] = err
}
deducePkgsGroup.Done()
}

for _, ip := range rd.externalImportList(params.stdLibFn) {
deducePkgsGroup.Add(1)
go checkPkg(ip, sm)
}

deducePkgsGroup.Wait()

if len(deductionErrs) > 0 {
return nil, deductionErrs
}

// Set up the bridge and ensure the root dir is in good, working order
// before doing anything else.
if params.mkBridgeFn == nil {
Expand Down

0 comments on commit bbde9bb

Please sign in to comment.