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

Default an empty constraint as any, not latest #901

Merged
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
4 changes: 2 additions & 2 deletions cmd/dep/testdata/glide/golden.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Detected glide configuration files...
Converting from glide.yaml and glide.lock...
Using master as initial constraint for imported dep github.com/sdboyer/deptest
Using ^2.0.0 as initial constraint for imported dep github.com/sdboyer/deptestdos
Using master as initial constraint for imported dep github.com/golang/lint
Using * as initial constraint for imported dep github.com/golang/lint
Trying v0.8.1 (3f4c3be) as initial lock for imported dep github.com/sdboyer/deptest
Trying v2.0.0 (5c60720) as initial lock for imported dep github.com/sdboyer/deptestdos
Trying master (cb00e56) as initial lock for imported dep github.com/golang/lint
Trying * (cb00e56) as initial lock for imported dep github.com/golang/lint
7 changes: 5 additions & 2 deletions internal/gps/source_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,10 @@ func (sm *SourceMgr) DeduceProjectRoot(ip string) (ProjectRoot, error) {
// string. Preference is given first for revisions, then branches, then semver
// constraints, and then plain tags.
func (sm *SourceMgr) InferConstraint(s string, pi ProjectIdentifier) (Constraint, error) {
if s == "" {
return Any(), nil
}

slen := len(s)
if slen == 40 {
if _, err := hex.DecodeString(s); err == nil {
Expand Down Expand Up @@ -539,8 +543,7 @@ func (sm *SourceMgr) InferConstraint(s string, pi ProjectIdentifier) (Constraint
}
SortPairedForUpgrade(versions)
for _, v := range versions {
// Pick the default branch if no constraint is given
if s == "" || s == v.String() {
if s == v.String() {
version = v
break
}
Expand Down
1 change: 1 addition & 0 deletions internal/gps/source_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func TestSourceManager_InferConstraint(t *testing.T) {
}

constraints := map[string]Constraint{
"": Any(),
"v0.8.1": sv,
"v2": NewBranch("v2"),
"v0.12.0-12-de4dcafe0": svs,
Expand Down