File tree 2 files changed +22
-7
lines changed
Filter options
2 files changed +22
-7
lines changed
Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ branches:
7
7
versions : [<1.1.2]
8
8
" 1.2 " :
9
9
time : 2015-02-19 10:59:35
10
- versions : [<1.2.2]
10
+ versions : [>=1.2.0, <1.2.2]
11
11
" 2.0 " :
12
12
time : 2015-02-19 10:59:35
13
- versions : [<2.0.3]
13
+ versions : [>=2.0.0, <2.0.3]
14
14
" 2.1 " :
15
15
time : 2015-02-19 10:59:35
16
- versions : [<2.1.2]
16
+ versions : [>=2.1.0, <2.1.2]
17
17
reference : composer://namshi/jose
Original file line number Diff line number Diff line change 84
84
continue ; // Don't validate branches when not set to avoid notices
85
85
}
86
86
87
+ $ upperBoundWithoutLowerBound = null ;
88
+
87
89
foreach ($ data ['branches ' ] as $ name => $ branch ) {
88
90
if (!preg_match ('/^([\d\.\-]+(\.x)?(\-dev)?|master)$/ ' , $ name )) {
89
91
$ messages [$ path ][] = sprintf ('Invalid branch name "%s". ' , $ name );
104
106
} elseif (!is_array ($ branch ['versions ' ])) {
105
107
$ messages [$ path ][] = sprintf ('"versions" must be an array for branch "%s". ' , $ name );
106
108
} else {
107
- $ hasMax = false ;
109
+ $ upperBound = null ;
110
+ $ hasMin = false ;
108
111
foreach ($ branch ['versions ' ] as $ version ) {
109
112
if ('< ' === substr ($ version , 0 , 1 )) {
110
- $ hasMax = true ;
111
- break ;
113
+ $ upperBound = $ version ;
114
+ continue ;
115
+ }
116
+ if ('> ' === substr ($ version , 0 , 1 )) {
117
+ $ hasMin = true ;
112
118
}
113
119
}
114
120
115
- if (! $ hasMax ) {
121
+ if (null === $ upperBound ) {
116
122
$ messages [$ path ][] = sprintf ('"versions" must have an upper bound for branch "%s". ' , $ name );
117
123
}
124
+
125
+ if (!$ hasMin && null === $ upperBoundWithoutLowerBound ) {
126
+ $ upperBoundWithoutLowerBound = $ upperBound ;
127
+ }
128
+
129
+ // Branches can omit the lower bound only if their upper bound is the same than for other branches without lower bound.
130
+ if (!$ hasMin && $ upperBoundWithoutLowerBound !== $ upperBound ) {
131
+ $ messages [$ path ][] = sprintf ('"versions" must have a lower bound for branch "%s" to avoid overlapping lower branches. ' , $ name );
132
+ }
118
133
}
119
134
}
120
135
} catch (ParseException $ e ) {
You can’t perform that action at this time.
0 commit comments