(defaultBranch: string, ruleChanges: string[] | {paths: string[]} | undefined, cwd: string)
| 353 | } |
| 354 | |
| 355 | static evaluateRuleChanges (defaultBranch: string, ruleChanges: string[] | {paths: string[]} | undefined, cwd: string): boolean { |
| 356 | if (ruleChanges === undefined) return true; |
| 357 | |
| 358 | // Normalize rules:changes:paths to rules:changes |
| 359 | if (!Array.isArray(ruleChanges)) ruleChanges = ruleChanges.paths; |
| 360 | |
| 361 | // NOTE: https://docs.gitlab.com/ee/ci/yaml/#ruleschanges |
| 362 | // Glob patterns are interpreted with Ruby's [File.fnmatch](https://docs.ruby-lang.org/en/master/File.html#method-c-fnmatch) |
| 363 | // with the flags File::FNM_PATHNAME | File::FNM_DOTMATCH | File::FNM_EXTGLOB. |
| 364 | return micromatch.some(GitData.changedFiles(`origin/${defaultBranch}`, cwd), ruleChanges, { |
| 365 | nonegate: true, |
| 366 | noextglob: true, |
| 367 | posix: false, |
| 368 | dot: true, |
| 369 | }); |
| 370 | } |
| 371 | |
| 372 | static isSubpath (lhs: string, rhs: string, cwd: string = process.cwd()) { |
| 373 | const absLhs = path.isAbsolute(lhs) ? lhs : path.resolve(cwd, lhs); |
no test coverage detected