Skip to content

Commit

Permalink
Merge pull request golang#901 from carolynvs/default-emptyconstraint-…
Browse files Browse the repository at this point in the history
…to-unconstrained

Default an empty constraint as any, not latest
  • Loading branch information
darkowlzz authored Jul 28, 2017
2 parents d558b52 + ca54d47 commit eb5b757
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
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

0 comments on commit eb5b757

Please sign in to comment.