@@ -199,7 +199,7 @@ export class Utils {
199
199
for ( const rule of opt . rules ) {
200
200
if ( ! Utils . evaluateRuleIf ( rule . if , opt . variables ) ) continue ;
201
201
if ( ! Utils . evaluateRuleExist ( opt . cwd , rule . exists ) ) continue ;
202
- if ( evaluateRuleChanges && ! Utils . evaluateRuleChanges ( gitData . branches . default , rule . changes ) ) continue ;
202
+ if ( evaluateRuleChanges && ! Utils . evaluateRuleChanges ( gitData . branches . default , rule . changes , opt . cwd ) ) continue ;
203
203
204
204
when = rule . when ? rule . when : jobWhen ;
205
205
allowFailure = rule . allow_failure ?? allowFailure ;
@@ -337,7 +337,7 @@ export class Utils {
337
337
return false ;
338
338
}
339
339
340
- static evaluateRuleChanges ( defaultBranch : string , ruleChanges : string [ ] | { paths : string [ ] } | undefined ) : boolean {
340
+ static evaluateRuleChanges ( defaultBranch : string , ruleChanges : string [ ] | { paths : string [ ] } | undefined , cwd : string ) : boolean {
341
341
if ( ruleChanges === undefined ) return true ;
342
342
343
343
// Normalize rules:changes:paths to rules:changes
@@ -346,7 +346,7 @@ export class Utils {
346
346
// NOTE: https://docs.gitlab.com/ee/ci/yaml/#ruleschanges
347
347
// Glob patterns are interpreted with Ruby's [File.fnmatch](https://docs.ruby-lang.org/en/master/File.html#method-c-fnmatch)
348
348
// with the flags File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB.
349
- return micromatch . some ( GitData . changedFiles ( `origin/${ defaultBranch } ` ) , ruleChanges , {
349
+ return micromatch . some ( GitData . changedFiles ( `origin/${ defaultBranch } ` , cwd ) , ruleChanges , {
350
350
nonegate : true ,
351
351
noextglob : true ,
352
352
posix : false ,
@@ -510,5 +510,12 @@ export class Utils {
510
510
511
511
static async stopDockerRegistry ( containerExecutable : string ) : Promise < void > {
512
512
await Utils . spawn ( [ containerExecutable , "rm" , "-f" , this . gclRegistryPrefix ] ) ;
513
+
514
+ static async getTrackedFiles ( cwd : string ) : Promise < string [ ] > {
515
+ const lsFilesRes = await Utils . bash ( "git ls-files --deduplicate" , cwd ) ;
516
+ if ( lsFilesRes . exitCode != 0 ) {
517
+ throw new Error ( `Failed to list tracked files in ${ cwd } : ${ lsFilesRes . stderr } ` ) ;
518
+ }
519
+ return lsFilesRes . stdout . split ( "\n" ) ;
513
520
}
514
521
}
0 commit comments