From bf68214325e7c83cfd1b64992030b83f373cbe98 Mon Sep 17 00:00:00 2001 From: Adrian Veliz Date: Mon, 15 Apr 2024 07:29:32 -0400 Subject: [PATCH] Add glob matching to include/exclude in diffable --- lib/plugins/diffable.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/plugins/diffable.js b/lib/plugins/diffable.js index 74871691..ed5fc0fb 100644 --- a/lib/plugins/diffable.js +++ b/lib/plugins/diffable.js @@ -22,6 +22,7 @@ const ErrorStash = require('./errorStash') const MergeDeep = require('../mergeDeep') const NopCommand = require('../nopcommand') +const Glob = require('../glob') const ignorableFields = ['id', 'node_id', 'default', 'url'] module.exports = class Diffable extends ErrorStash { constructor (nop, github, repo, entries, log, errors) { @@ -39,7 +40,10 @@ module.exports = class Diffable extends ErrorStash { // this.log.debug(` entries ${JSON.stringify(filteredEntries)}`) filteredEntries = filteredEntries.filter(attrs => { if (Array.isArray(attrs.exclude)) { - if (!attrs.exclude.includes(this.repo.repo)) { + const excludeGlobs = attrs.exclude.map(exc => new Glob(exc)); + const excludeGlobsMatch = excludeGlobs.some(glob => !!this.repo.repo.match(glob)); + + if (!attrs.exclude.includes(this.repo.repo) && !excludeGlobsMatch) { // this.log.debug(`returning not excluded entry = ${JSON.stringify(attrs)} for repo ${this.repo.repo}`) return true } else { @@ -53,7 +57,10 @@ module.exports = class Diffable extends ErrorStash { }) filteredEntries = filteredEntries.filter(attrs => { if (Array.isArray(attrs.include)) { - if (attrs.include.includes(this.repo.repo)) { + const includeGlobs = attrs.include.map(inc => new Glob(inc)); + const includeGlobsMatch = includeGlobs.some(glob => !!this.repo.repo.match(glob)); + + if (attrs.include.includes(this.repo.repo) || includeGlobsMatch) { // this.log.debug(`returning included entry = ${JSON.stringify(attrs)} for repo ${this.repo.repo}`) return true } else {