klarna / bec

The BitBucket Erlang Client
Apache License 2.0
47 stars 12 forks source link

BEC shall not delete merge checks when enforcing hooks #15

Open robertoaloi opened 3 years ago

robertoaloi commented 3 years ago

Consider a repo with some basic PR restrictions and hooks:

pr-restrictions:
  required-approvers: 2
  required-successful-builds: 1
  required-all-approvers: true
  required-all-tasks-complete: true

hooks:
  - key: com.klarna.bitbucket.needs-work-check:needsWorkBlocker
    enabled: true
    settings: {}

In recent versions of Bitbucket the PR restrictions are implemented via merge check hooks, and are listed as hooks too on the REST interface.

The problem is that when someone changes the hooks for this repo, and BEC enforces the hooks, it also deletes the merge check hooks. Then it has to enforce the pr restrictions again.

It's just pure luck that hooks are checked before pr restrictions, so at the end we arrive to the correct config. But this should be fixed.