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

Commit 6a28486

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

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

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)