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

Fix missing branch in dep ensure -add: introduce hoist from lock #994

Merged
merged 3 commits into from
Aug 12, 2017
Merged
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
28 changes: 22 additions & 6 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ package main
import (
"bytes"
"flag"
"fmt"
"go/build"
"os"
"path/filepath"
Expand Down Expand Up @@ -585,13 +586,28 @@ func (cmd *ensureCommand) runAdd(ctx *dep.Ctx, args []string, p *dep.Project, sm
reqlist = append(reqlist, path)
}

if !gps.IsAny(instr.constraint) || instr.id.Source != "" {
appender.Constraints[pr] = gps.ProjectProperties{
Source: instr.id.Source,
Constraint: instr.constraint,
if instr.typ&isInManifest == 0 {
var pp gps.ProjectProperties
var found bool
for _, proj := range solution.Projects() {
// We compare just ProjectRoot instead of the whole
// ProjectIdentifier here because an empty source on the input side
// could have been converted into a source by the solver.
if proj.Ident().ProjectRoot == pr {
found = true
pp = getProjectPropertiesFromVersion(proj.Version())
break
}
}
if !found {
panic(fmt.Sprintf("unreachable: solution did not contain -add argument %s, but solver did not fail", pr))
}
pp.Source = instr.id.Source

if !gps.IsAny(instr.constraint) {
pp.Constraint = instr.constraint
}
//} else {
// TODO(sdboyer) hoist a constraint into the manifest from the lock
appender.Constraints[pr] = pp
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"

[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptesttres"
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,7 @@
[[constraint]]
branch = "master"
name = "github.com/sdboyer/deptesttres"

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"