RFR: 1173: Dependent PR feature does not work with protected branches in newer Gitlab version

Erik Joelsson erikj at openjdk.org
Tue Jan 3 17:28:43 UTC 2023

In GitLab, if a branch is protected, it cannot be removed. This is preventing us from using the pr/X feature of Skara to support dependent pull requests. This patch adds the ability to dynamically protect and unprotect branch patterns when creating pr/X branches. This is controlled with a new configuration option on the prbranch notifier like this:

        "prbranch": {
          "protect": true,

The semantics needed for GitLab is to first add a pattern based protection rule, then create the branch. Unfortunately, I couldn't easily implement the same semantics for GitHubRepository. The REST API for branch protection in GitHub doesn't allow patterns, only existing branches. It could probably be done using GraphQL, but given how complicated that would be to implement, I chose not to, since we don't actually need this feature on GitHub. (GitHub branch protection is flexible enough so we can have a static configuration that allows admins to delete branches, and this is already in use today)

I have tested the basic branch protection functionality using the new manual test and I have run the notifier bot with the new configuration against a playground repository in GitLab and manually created and closed PRs.


Commit messages:
 - Restore manual annotation
 - Must encode refs in URLs
 - SKARA-1173

Changes: https://git.openjdk.org/skara/pull/1452/files
 Webrev: https://webrevs.openjdk.org/?repo=skara&pr=1452&range=00
  Issue: https://bugs.openjdk.org/browse/SKARA-1173
  Stats: 128 lines in 9 files changed: 122 ins; 1 del; 5 mod
  Patch: https://git.openjdk.org/skara/pull/1452.diff
  Fetch: git fetch https://git.openjdk.org/skara pull/1452/head:pull/1452

PR: https://git.openjdk.org/skara/pull/1452

More information about the skara-dev mailing list