@@ -130,19 +130,19 @@ const exclusiveLabelsMap = new Map([
130
130
[ / ^ b e n c h m a r k \/ / , 'benchmark' ]
131
131
] )
132
132
133
- function resolveLabels ( filepathsChanged , baseBranch , limitLib = true ) {
133
+ function resolveLabels ( filepathsChanged , baseBranch , limitLabels = true ) {
134
134
const exclusiveLabels = matchExclusiveSubSystem ( filepathsChanged )
135
135
136
136
if ( typeof baseBranch !== 'string' ) {
137
137
if ( typeof baseBranch === 'boolean' ) {
138
- limitLib = baseBranch
138
+ limitLabels = baseBranch
139
139
}
140
140
baseBranch = ''
141
141
}
142
142
143
143
const labels = ( exclusiveLabels . length > 0 )
144
144
? exclusiveLabels
145
- : matchAllSubSystem ( filepathsChanged , limitLib )
145
+ : matchAllSubSystem ( filepathsChanged , limitLabels )
146
146
147
147
// Add version labels if PR is made against a version branch
148
148
const m = / ^ ( v \d + \. (?: \d + | x ) ) (?: - s t a g i n g | $ ) / . exec ( baseBranch )
@@ -195,13 +195,13 @@ function matchExclusiveSubSystem (filepathsChanged) {
195
195
return isExclusive ? labels : [ ]
196
196
}
197
197
198
- function matchAllSubSystem ( filepathsChanged , limitLib ) {
198
+ function matchAllSubSystem ( filepathsChanged , limitLabels ) {
199
199
return matchSubSystemsByRegex (
200
- subSystemLabelsMap , filepathsChanged , limitLib )
200
+ subSystemLabelsMap , filepathsChanged , limitLabels )
201
201
}
202
202
203
- function matchSubSystemsByRegex ( rxLabelsMap , filepathsChanged , limitLib ) {
204
- const jsLabelCount = [ ]
203
+ function matchSubSystemsByRegex ( rxLabelsMap , filepathsChanged , limitLabels ) {
204
+ const labelCount = [ ]
205
205
// by putting matched labels into a map, we avoid duplicate labels
206
206
const labelsMap = filepathsChanged . reduce ( ( map , filepath ) => {
207
207
const mappedSubSystems = mappedSubSystemsForFile ( rxLabelsMap , filepath )
@@ -213,16 +213,17 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged, limitLib) {
213
213
214
214
for ( var i = 0 ; i < mappedSubSystems . length ; ++ i ) {
215
215
const mappedSubSystem = mappedSubSystems [ i ]
216
- if ( limitLib && hasJsSubsystemChanges ( filepathsChanged , mappedSubSystem ) ) {
217
- if ( jsLabelCount . length >= 4 ) {
218
- for ( const jsLabel of jsLabelCount ) {
219
- delete map [ jsLabel ]
216
+ if ( limitLabels && hasLibOrSrcChanges ( filepathsChanged ) ) {
217
+ if ( labelCount . length >= 4 ) {
218
+ for ( const label of labelCount ) {
219
+ // don't delete the c++ label as we always want that if it has matched
220
+ if ( label !== 'c++' ) delete map [ label ]
220
221
}
221
222
map [ 'lib / src' ] = true
222
223
// short-circuit
223
224
return map
224
225
} else {
225
- jsLabelCount . push ( mappedSubSystem )
226
+ labelCount . push ( mappedSubSystem )
226
227
}
227
228
}
228
229
@@ -235,9 +236,8 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged, limitLib) {
235
236
return Object . keys ( labelsMap )
236
237
}
237
238
238
- function hasJsSubsystemChanges ( filepathsChanged , mappedSubSystem ) {
239
- const hasLibChanges = filepathsChanged . some ( ( filepath ) => filepath . startsWith ( 'lib/' ) )
240
- return hasLibChanges && jsSubsystemList . includes ( mappedSubSystem )
239
+ function hasLibOrSrcChanges ( filepathsChanged ) {
240
+ return filepathsChanged . some ( ( filepath ) => filepath . startsWith ( 'lib/' ) || filepath . startsWith ( 'src/' ) )
241
241
}
242
242
243
243
function mappedSubSystemsForFile ( labelsMap , filepath ) {
0 commit comments