Skip to content

Adding BypassPullRequestActorIDs to branch protection - #1030

Merged
kfcampbell merged 1 commit into
integrations:mainfrom
jtyr:jtyr-bypass
Mar 11, 2022
Merged

kfcampbell merged 1 commit into
integrations:mainfrom
jtyr:jtyr-bypass

Conversation

@jtyr

@jtyr jtyr commented Jan 11, 2022 •

Copy link
Copy Markdown
Contributor

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.

@majormoses majormoses left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@wagnst

wagnst commented Jan 22, 2022

Copy link
Copy Markdown

Can we get this shipped please? :-)

@jtyr

jtyr commented Jan 28, 2022

Copy link
Copy Markdown
Contributor Author

@jcudit please could you review this PR?

@kfcampbell kfcampbell left a comment

Copy link
Copy Markdown
Contributor

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?

Comment thread github/util_v4.go
return vGh4
}

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

Copy link
Copy Markdown
Contributor

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
Copy Markdown
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
Copy Markdown
Contributor

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?

@jtyr jtyr Feb 9, 2022 •

Copy link
Copy Markdown
Contributor Author

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
Copy Markdown

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

@dylanturn

Copy link
Copy Markdown

Also interested in seeing this get merged, pretty please!

@kfcampbell kfcampbell left a comment

Copy link
Copy Markdown
Contributor

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
Copy Markdown
Contributor

Thanks a ton for submitting this functionality.

@dylanturn

Copy link
Copy Markdown

Any idea when this will be merged?

@chenshap

Copy link
Copy Markdown

@kfcampbell

Copy link
Copy Markdown
Contributor

@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