From 8fe401bd1e2b52c00a427bed5fbb76a003b3358f Mon Sep 17 00:00:00 2001 From: "Stephen J. Collings" Date: Wed, 28 Feb 2024 17:13:35 +0000 Subject: [PATCH] fix(rulesets): Repo scope update trying to remove org rulesets (#595) --- lib/plugins/rulesets.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/plugins/rulesets.js b/lib/plugins/rulesets.js index a62b5d91..6846e1ce 100644 --- a/lib/plugins/rulesets.js +++ b/lib/plugins/rulesets.js @@ -54,15 +54,17 @@ module.exports = class Rulesets extends Diffable { this.log(listOptions) return this.github.paginate(listOptions) .then(res => { - const rulesets = res.map(ruleset => { - const getOptions = this.github.request.endpoint.merge('GET /repos/{owner}/{repo}/rulesets/{id}', { - owner: this.repo.owner, - repo: this.repo.repo, - id: ruleset.id, - headers: version + const rulesets = res + .filter(ruleset => ruleset.source_type === 'Repository') + .map(ruleset => { + const getOptions = this.github.request.endpoint.merge('GET /repos/{owner}/{repo}/rulesets/{id}', { + owner: this.repo.owner, + repo: this.repo.repo, + id: ruleset.id, + headers: version + }) + return this.github.paginate(getOptions) }) - return this.github.paginate(getOptions) - }) return Promise.all(rulesets).then(res => { return res ? res.flat(1) : [] })