зеркало из https://github.com/golang/dep.git
Handle nil v in LockedProject.Eq()
This commit is contained in:
Родитель
619c3f6856
Коммит
d10c21db71
9
lock.go
9
lock.go
|
@ -167,7 +167,14 @@ func (lp LockedProject) Eq(lp2 LockedProject) bool {
|
|||
}
|
||||
}
|
||||
|
||||
if !lp.v.Matches(lp2.v) {
|
||||
v1n := lp.v == nil
|
||||
v2n := lp2.v == nil
|
||||
|
||||
if v1n != v2n {
|
||||
return false
|
||||
}
|
||||
|
||||
if !v1n && !lp.v.Matches(lp2.v) {
|
||||
return false
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ func TestLockedProjectsEq(t *testing.T) {
|
|||
NewLockedProject(mkPI("github.com/sdboyer/gps"), NewVersion("v0.10.0"), []string{"flugle", "gps"}),
|
||||
NewLockedProject(mkPI("github.com/sdboyer/gps"), NewVersion("v0.10.0").Is("278a227dfc3d595a33a77ff3f841fd8ca1bc8cd0"), []string{"gps"}),
|
||||
NewLockedProject(mkPI("github.com/sdboyer/gps"), NewVersion("v0.11.0"), []string{"gps"}),
|
||||
NewLockedProject(mkPI("github.com/sdboyer/gps"), Revision("278a227dfc3d595a33a77ff3f841fd8ca1bc8cd0"), []string{"gps"}),
|
||||
}
|
||||
|
||||
fix := []struct {
|
||||
|
@ -49,6 +50,8 @@ func TestLockedProjectsEq(t *testing.T) {
|
|||
{0, 2, false, "should not eq when other pkg list is longer"},
|
||||
{2, 4, false, "should not eq when pkg lists are out of order"},
|
||||
{0, 3, false, "should not eq totally different lp"},
|
||||
{7, 7, true, "should eq with only rev"},
|
||||
{5, 7, false, "should not eq when only rev matches"},
|
||||
}
|
||||
|
||||
for _, f := range fix {
|
||||
|
|
Загрузка…
Ссылка в новой задаче