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 May 1, 2017
1 parent 7a984f5 commit 76be346
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,6 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
}
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 @@ -300,13 +291,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 @@ -315,12 +304,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 76be346

Please sign in to comment.