@@ -130,19 +130,19 @@ const exclusiveLabelsMap = new Map([
130130[ / ^ b e n c h m a r k \/ / , 'benchmark' ]
131131] )
132132
133- function resolveLabels ( filepathsChanged , baseBranch , limitLib = true ) {
133+ function resolveLabels ( filepathsChanged , baseBranch , limitLabels = true ) {
134134const exclusiveLabels = matchExclusiveSubSystem ( filepathsChanged )
135135
136136if ( typeof baseBranch !== 'string' ) {
137137if ( typeof baseBranch === 'boolean' ) {
138- limitLib = baseBranch
138+ limitLabels = baseBranch
139139}
140140baseBranch = ''
141141}
142142
143143const labels = ( exclusiveLabels . length > 0 )
144144 ? exclusiveLabels
145- : matchAllSubSystem ( filepathsChanged , limitLib )
145+ : matchAllSubSystem ( filepathsChanged , limitLabels )
146146
147147// Add version labels if PR is made against a version branch
148148const m = / ^ ( v \d + \. (?: \d + | x ) ) (?: - s t a g i n g | $ ) / . exec ( baseBranch )
@@ -195,13 +195,13 @@ function matchExclusiveSubSystem (filepathsChanged){
195195return isExclusive ? labels : [ ]
196196}
197197
198- function matchAllSubSystem ( filepathsChanged , limitLib ) {
198+ function matchAllSubSystem ( filepathsChanged , limitLabels ) {
199199return matchSubSystemsByRegex (
200- subSystemLabelsMap , filepathsChanged , limitLib )
200+ subSystemLabelsMap , filepathsChanged , limitLabels )
201201}
202202
203- function matchSubSystemsByRegex ( rxLabelsMap , filepathsChanged , limitLib ) {
204- const jsLabelCount = [ ]
203+ function matchSubSystemsByRegex ( rxLabelsMap , filepathsChanged , limitLabels ) {
204+ const labelCount = [ ]
205205// by putting matched labels into a map, we avoid duplicate labels
206206const labelsMap = filepathsChanged . reduce ( ( map , filepath ) => {
207207const mappedSubSystems = mappedSubSystemsForFile ( rxLabelsMap , filepath )
@@ -213,16 +213,17 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged, limitLib){
213213
214214for ( var i = 0 ; i < mappedSubSystems . length ; ++ i ) {
215215const 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 ]
220221}
221222map [ 'lib / src' ] = true
222223// short-circuit
223224return map
224225} else {
225- jsLabelCount . push ( mappedSubSystem )
226+ labelCount . push ( mappedSubSystem )
226227}
227228}
228229
@@ -235,9 +236,8 @@ function matchSubSystemsByRegex (rxLabelsMap, filepathsChanged, limitLib){
235236return Object . keys ( labelsMap )
236237}
237238
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/' ) )
241241}
242242
243243function mappedSubSystemsForFile ( labelsMap , filepath ) {
0 commit comments