app icon indicating copy to clipboard operation
app copied to clipboard

Branch protection settings don't work for wildcards

Open iphydf opened this issue 5 years ago • 16 comments

Problem Description

Setting "name" to "*" in "branches:" doesn't do anything. Github supports wildcard matching of branches, and I'd like to be able to (I do, in my manual settings) apply branch protection rules to all branches in a repo.

What is actually happening

Nothing.

What is the expected behavior

A branch protection rule with "*" as name should appear.

Error output, if available

Question: where would I see the errors?

Context

Are you using the hosted instance of probot/settings or running your own?

Hosted.

iphydf avatar Apr 24 '20 19:04 iphydf

please be sure to look for similar issues when reporting problems. it sounds like this is a similar problem to what was reported in https://github.com/probot/settings/issues/136. are there any details in there that might help you get past this issue.

I havent had time to diagnose this issue very far, but if you dig deep enough to identify further details around the problem, i'm happy to guide further and would certainly be open to a PR if we can get far enough to decide what would help here. if you are able to confirm whether it works through the api outside of the settings app, such as with a curl request, that would be a huge help.

Question: where would I see the errors?

good question. since you mentioned using the hosted version, you wouldn't see them currently. this is why we ask whether you use the hosted version vs run your own. if you were running your own, you would have access to logs for your instance and could include details from there. one of the other high priority improvements planned is to include some of these details as part of check runs, so that you can see the reason for failures, even if you are using our hosted version.

travi avatar Apr 24 '20 20:04 travi

The solution is probably similar. TBH if I look at the github API docs, it doesn't look like they have support for this (the API call is something like /.../:branch/..., indicating that the branch must exist - the wildcard feature was added later, and it seems the API hasn't adapted yet), so there isn't much you can do right now other than contacting github about this feature request.

iphydf avatar Apr 24 '20 21:04 iphydf

there isn't much you can do right now other than contacting github about this feature request.

unfortunately, this is somewhat common with requests for additions to the settings app. i would encourage reaching out to github support with requesting the addition. if you get a useful response back, please include the details in appropriate issues here so we better understand the status.

travi avatar Apr 24 '20 21:04 travi

I don't believe this is an API issue, I tested this now and the API supports wildcards

mutation MyMutation {
  __typename
  createBranchProtectionRule(input: {repositoryId: "XXXXXXXXXXXXXXXXXX", pattern: "foobar*", restrictsPushes: false}) {
    clientMutationId
  }
}

This is the same for #136, also works fine with the graphql API.

mkrakowitzer avatar May 26 '20 22:05 mkrakowitzer

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

stale[bot] avatar Aug 29 '20 09:08 stale[bot]

Hi All,

This is one of the features which we are badly waiting for. We use wildcards extensively to protect branches today, for example, any branch starting with release should be automatically protected. This is a critical feature in very rapid development repositories where more developers are actively working on. Adoption of settings bot in our organization has been very successful so far except for the most critical repositories, just because of this missing feature.

sagarvsh avatar Aug 30 '20 00:08 sagarvsh

this is functionality that i would very much like to see as well, but as a single maintainer, time has been tight for working on features like this. if this is important to you, i encourage you to work on adding the functionality and submit a pull-request. i'm happy to help you work through the details along the way if you decide to make such a contribution.

travi avatar Aug 30 '20 01:08 travi

This is the same for #136, also works fine with the graphql API.

so, it looks like we need to use graphql endpoint. can the bot already do that?

edit: doesn't appear so. @travi would you support adding graphql to the bot? i can contribute the change if you can review...

https://docs.github.com/en/graphql/guides/migrating-from-rest-to-graphql

dennisroche avatar Aug 23 '21 13:08 dennisroche

Has anyone done this work on the side (and perhaps not contributed it back for integration) - it's causing sufficient irritation to us in our workflow that I'll have one of my team implement this if necessary.

(We currently have custom code that uses the GraphQL mutation to do the work - but it's becoming annoying having probot for some repos, and custom code for others).

bwalding avatar Jul 26 '22 23:07 bwalding

@bwalding

I'll have one of my team implement this if necessary

Did your team done it? Is there any related PR?

electriquo avatar Dec 12 '22 14:12 electriquo

Any progress here?

dan-ih avatar Dec 22 '22 20:12 dan-ih

We need to cast our votes on Update branch protection wildcard on GitHub API and Webhooks feedback

electriquo avatar Jan 01 '23 10:01 electriquo

@bwalding

I'll have one of my team implement this if necessary

Did your team done it? Is there any related PR?

There wasn't any feedback from a maintainer - so I figured no real appetite for implementing.

bwalding avatar Jan 06 '23 07:01 bwalding

@bwalding Please consider solving the community pain once and for all :)

electriquo avatar Jan 08 '23 08:01 electriquo

What's needed to implement this? Is it difficult?

iphydf avatar Nov 23 '23 11:11 iphydf