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

fix dep silently failing #307

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"encoding/hex"
"flag"
"fmt"
"go/build"
"log"
"os"
"path/filepath"
Expand Down Expand Up @@ -128,6 +129,10 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
return errors.Wrap(err, "ensure ListPackage for project")
}

if err := checkErrors(params.RootPackageTree.Packages); err != nil {
return err
}

if cmd.update {
applyUpdateArgs(args, &params)
} else {
Expand Down Expand Up @@ -362,3 +367,30 @@ func deduceConstraint(s string) gps.Constraint {
// TODO: if there is amgibuity here, then prompt the user?
return gps.NewVersion(s)
}

func checkErrors(m map[string]gps.PackageOrErr) error {
noGoErrors, pkgErrors := 0, 0
for _, poe := range m {
if poe.Err != nil {
switch poe.Err.(type) {
case *build.NoGoError:
noGoErrors++
default:
pkgErrors++
}
}
}
if len(m) == 0 || len(m) == noGoErrors {
return errors.New("all dirs lacked any go code")
}

if len(m) == pkgErrors {
return errors.New("all dirs had go code with errors")
}

if len(m) == pkgErrors+noGoErrors {
return fmt.Errorf("%d dirs had errors and %d had no go code", pkgErrors, noGoErrors)
}

return nil
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"memo": "",
"projects": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"commands": [
["init"],
["ensure"]
]
}