Allow 2 point versions in images:
We only use 2 points X.Y always unless there is really a patch which is extremely uncommon. Developers choose the X and tooling chooses the Y. That is the developers only ever have to make a simple decision did I break it or not. * these are still semver but just treat the patch as optional * add tests for various combinations of updatespull/513/head
parent
463b39fdbd
commit
b42d7a2e97
|
@ -69,7 +69,7 @@ func shouldUpdate(spt SemverPolicyType, matchPreRelease bool, current, new strin
|
|||
}
|
||||
|
||||
parts := strings.SplitN(new, ".", 3)
|
||||
if len(parts) != 3 {
|
||||
if len(parts) != 2 && len(parts) != 3 {
|
||||
return false, ErrNoMajorMinorPatchElementsFound
|
||||
}
|
||||
|
||||
|
|
|
@ -47,6 +47,16 @@ func Test_shouldUpdate(t *testing.T) {
|
|||
want: false,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "minor increase - 2 points, policy all",
|
||||
args: args{
|
||||
current: "1.4",
|
||||
new: "1.5",
|
||||
spt: SemverPolicyTypeAll,
|
||||
},
|
||||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "minor increase, policy major",
|
||||
args: args{
|
||||
|
@ -77,6 +87,26 @@ func Test_shouldUpdate(t *testing.T) {
|
|||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "patch release, policy patch",
|
||||
args: args{
|
||||
current: "1.4",
|
||||
new: "1.4.6",
|
||||
spt: SemverPolicyTypePatch,
|
||||
},
|
||||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "minor and patch release, policy patch",
|
||||
args: args{
|
||||
current: "1.4",
|
||||
new: "1.5.6",
|
||||
spt: SemverPolicyTypePatch,
|
||||
},
|
||||
want: false,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "patch decrease, policy patch",
|
||||
args: args{
|
||||
|
@ -87,6 +117,16 @@ func Test_shouldUpdate(t *testing.T) {
|
|||
want: false,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "2 points minor change, policy patch",
|
||||
args: args{
|
||||
current: "1.4",
|
||||
new: "1.5",
|
||||
spt: SemverPolicyTypePatch,
|
||||
},
|
||||
want: false,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "patch AND major increase, policy patch",
|
||||
args: args{
|
||||
|
@ -117,6 +157,16 @@ func Test_shouldUpdate(t *testing.T) {
|
|||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "minor increase 2 points, policy minor",
|
||||
args: args{
|
||||
current: "1.4",
|
||||
new: "1.5",
|
||||
spt: SemverPolicyTypeMinor,
|
||||
},
|
||||
want: true,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "patch increase, policy minor",
|
||||
args: args{
|
||||
|
|
Loading…
Reference in New Issue