Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add glob matching to include/exclude in diffable #622

Open
wants to merge 1 commit into
base: main-enterprise
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/plugins/diffable.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down