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

Commit ca54d47

Browse files
committed
Default empty constraints to any, not the default branch
1 parent 0a63c47 commit ca54d47

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

cmd/dep/testdata/glide/golden.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Detected glide configuration files...
22
Converting from glide.yaml and glide.lock...
33
Using master as initial constraint for imported dep github.com/sdboyer/deptest
44
Using ^2.0.0 as initial constraint for imported dep github.com/sdboyer/deptestdos
5-
Using master as initial constraint for imported dep github.com/golang/lint
5+
Using * as initial constraint for imported dep github.com/golang/lint
66
Trying v0.8.1 (3f4c3be) as initial lock for imported dep github.com/sdboyer/deptest
77
Trying v2.0.0 (5c60720) as initial lock for imported dep github.com/sdboyer/deptestdos
8-
Trying master (cb00e56) as initial lock for imported dep github.com/golang/lint
8+
Trying * (cb00e56) as initial lock for imported dep github.com/golang/lint

internal/gps/source_manager.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,10 @@ func (sm *SourceMgr) DeduceProjectRoot(ip string) (ProjectRoot, error) {
502502
// string. Preference is given first for revisions, then branches, then semver
503503
// constraints, and then plain tags.
504504
func (sm *SourceMgr) InferConstraint(s string, pi ProjectIdentifier) (Constraint, error) {
505+
if s == "" {
506+
return Any(), nil
507+
}
508+
505509
slen := len(s)
506510
if slen == 40 {
507511
if _, err := hex.DecodeString(s); err == nil {
@@ -539,8 +543,7 @@ func (sm *SourceMgr) InferConstraint(s string, pi ProjectIdentifier) (Constraint
539543
}
540544
SortPairedForUpgrade(versions)
541545
for _, v := range versions {
542-
// Pick the default branch if no constraint is given
543-
if s == "" || s == v.String() {
546+
if s == v.String() {
544547
version = v
545548
break
546549
}

internal/gps/source_manager_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ func TestSourceManager_InferConstraint(t *testing.T) {
3030
}
3131

3232
constraints := map[string]Constraint{
33+
"": Any(),
3334
"v0.8.1": sv,
3435
"v2": NewBranch("v2"),
3536
"v0.12.0-12-de4dcafe0": svs,

0 commit comments

Comments
 (0)