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

Commit

Permalink
First bits of -update path
Browse files Browse the repository at this point in the history
  • Loading branch information
sdboyer committed Apr 30, 2017
1 parent aa0dee8 commit d3bf178
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,23 +172,13 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
return errors.Wrap(err, "ensure ListPackage for project")
}

var fail error
if cmd.add {
return cmd.runAdd(ctx, args, p, sm, params)
} else if cmd.update {
return cmd.runUpdate(ctx, args, p, sm, params)
}
return cmd.runDefault(ctx, args, p, sm, params)

if cmd.update {
applyUpdateArgs(args, &params)
} else {
err := applyEnsureArgs(args, cmd.overrides, p, sm, &params)
if err != nil {
return err
}
}

solver, err := gps.Prepare(params, sm)
if err != nil {
return errors.Wrap(err, "ensure Prepare")
Expand Down Expand Up @@ -295,13 +285,11 @@ func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project
return nil
}

func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.SourceManager, params gps.SolveParameters) error {
}

func (cmd *ensureCommand) runUpdate(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.SourceManager, params gps.SolveParameters) error {
}
if p.Lock == nil {
return errors.New("%s does not exist. nothing to do, as -update works by updating the values in %s.", dep.LockName, dep.LockName)
}

func applyUpdateArgs(args []string, params *gps.SolveParameters) {
// When -update is specified without args, allow every project to change versions, regardless of the lock file
if len(args) == 0 {
params.ChangeAll = true
Expand All @@ -310,12 +298,30 @@ func applyUpdateArgs(args []string, params *gps.SolveParameters) {

// Allow any of specified project versions to change, regardless of the lock file
for _, arg := range args {
// Ensure the provided path has a deducible project root
// TODO(sdboyer) do these concurrently
pc, err := getProjectConstraint(arg, sm)
if err != nil {
// TODO(sdboyer) return all errors, not just the first one we encounter
// TODO(sdboyer) ensure these errors are contextualized in a
// sensible way for -update
return err
}

if !gps.IsAny(pc.Constraint) {
// TODO(sdboyer) constraints should be allowed to allow solves that
// target particular versions while remaining within declared constraints
return errors.Errorf("-update operates according to constraints declared in %s, not CLI arguments.\nYou passed in %s for %s", dep.ManifestName, pc.Constraint, pc.Ident.ProjectRoot)
}

params.ToChange = append(params.ToChange, gps.ProjectRoot(arg))
}
}

func applyEnsureArgs(args []string, overrides stringSlice, p *dep.Project, sm *gps.SourceMgr, params *gps.SolveParameters) error {
func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.SourceManager, params gps.SolveParameters) error {
}

func applyEnsureArgs(args []string, overrides stringSlice, p *dep.Project, sm *gps.SourceMgr, params *gps.SolveParameters) error {
var errs []error
for _, arg := range args {
pc, err := getProjectConstraint(arg, sm)
Expand Down

0 comments on commit d3bf178

Please sign in to comment.