Skip to content

Commit

Permalink
feat(rulesets): enable updating existing rulesets
Browse files Browse the repository at this point in the history
for #732
  • Loading branch information
travi committed Sep 15, 2024
1 parent 88683ec commit e8221c3
Show file tree
Hide file tree
Showing 6 changed files with 123 additions and 40 deletions.
18 changes: 16 additions & 2 deletions lib/plugins/rulesets.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
import deepEqual from 'deep-equal'

import Diffable from './diffable.js'

export default class Rulesets extends Diffable {
async find () {
await this.github.repos.getRepoRulesets(this.repo)
const { data: rulesets } = await this.github.repos.getRepoRulesets(this.repo)

return rulesets
}

comparator (existing, attrs) {
return existing.name === attrs.name
}

changed (existing, attrs) {
return !deepEqual(existing, attrs)
}

return []
update (existing, attrs) {
this.github.repos.updateRepoRuleset({ ...this.repo, ruleset_id: existing.ruleset_id, ...attrs })
}

async add (attrs) {
Expand Down
83 changes: 49 additions & 34 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"author": "Brandon Keepers",
"license": "ISC",
"dependencies": {
"deep-equal": "^2.2.3",
"deepmerge": "4.3.1",
"js-yaml": "4.1.0",
"probot": "13.3.7"
Expand Down
1 change: 0 additions & 1 deletion test/integration/features/rulesets.feature
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ Feature: Repository Rulesets
When a settings sync is triggered
Then the ruleset is enabled for the repository

@wip
Scenario: Update a ruleset
Given a ruleset exists for the repository
And the ruleset is modified in the config
Expand Down
Loading

0 comments on commit e8221c3

Please sign in to comment.