Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding BypassPullRequestActorIDs to branch protection #1030

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

jtyr
Copy link
Contributor

@jtyr jtyr commented Jan 11, 2022

This PR is fixing the issue #1005 by adding the functionality to define a list of users/teams that can bypass the PR restrictions. Unfortunately there doesn't seem to be any boolean flag like in the case of the restrict_dismissals + dismissal_restrictions parameters.

Copy link
Contributor

@majormoses majormoses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@wagnst
Copy link

wagnst commented Jan 22, 2022

Can we get this shipped please? :-)

@jtyr
Copy link
Contributor Author

jtyr commented Jan 28, 2022

@jcudit please could you review this PR?

Copy link
Member

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had a few initial questions. I like this feature addition a lot.

Can you add tests to cover this change?

@@ -37,6 +37,14 @@ func githubv4IDSlice(ss []string) []githubv4.ID {
return vGh4
}

func githubv4IDSliceEmpty(ss []string) []githubv4.ID {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is "Empty" in the name here? It looks like the function is a translation between a string slice and a githubv4.ID slice, and I'm not quite understanding how Empty fits in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember it correctly, I had to add this here so we can set the list of pull_request_bypassers to empty list:

resource "github_branch_protection" "test" {
  ...
  required_pull_request_reviews {
    pull_request_bypassers = []
  }
}

Without this we cannot remove all bypassers if any were set before.

I didn't want to make changes to the githubv4IDSlice for the case some other logic would break so I added this new function. If you feel the function should be called differently, plese suggest a new name and I will amend it.

Comment on lines +237 to +242
if a.Actor.Team != (Actor{}) {
bypassActors = append(bypassActors, a.Actor.Team.ID.(string))
}
if a.Actor.User != (Actor{}) {
bypassActors = append(bypassActors, a.Actor.User.ID.(string))
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind explaining this logic to me a little more?

Copy link
Contributor Author

@jtyr jtyr Feb 9, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic is the same like in the case of setPushActorIDs bellow.

@kfcampbell kfcampbell added this to the v4.21.0 milestone Feb 2, 2022
@atorrescogollo
Copy link

Any update on this? I am very interested in having this merged :)

@dylanturn
Copy link

Also interested in seeing this get merged, pretty please!

Copy link
Member

@kfcampbell kfcampbell left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good to merge!

@kfcampbell
Copy link
Member

Thanks a ton for submitting this functionality.

@dylanturn
Copy link

Any idea when this will be merged?

@chenshap
Copy link

Hi,
Is it planned to be added to github_branch_protection_v3?
https://registry.terraform.io/providers/integrations/github/latest/docs/resources/branch_protection_v3

@kfcampbell
Copy link
Member

@chenshap I didn't have immediate plans to do so, but if you'd like to open a PR I'd be receptive to reviewing it and getting it in!

kfcampbell pushed a commit to kfcampbell/terraform-provider-github that referenced this pull request Jul 26, 2022
kazaker pushed a commit to auto1-oss/terraform-provider-github that referenced this pull request Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants