Skip to content

[FEAT]: Require approval from someone other than the last pusher #1352

Closed

Description

Describe the need

I see that at least according to the branch_protection documentation of the currently latest version (5.7.0) the "Require approval from someone other than the last pusher" option isn't available for the required_pull_request_reviews parameter.

That boolean option would be very important for my use case, and its name could be e.g. require_non_last_pusher_approval.

SDK Version

No response

API Version

No response

Relevant log output

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. ghost added
    Status: Triage
    on Nov 8, 2022
  2. ghost added
    Type: Feature
    on Nov 8, 2022
  3. fproulx-boostsecurity commented on Nov 9, 2022

    @fproulx-boostsecurity

    This is such an important improvement to branch protection. I hope this will go in soon.

  4. kfcampbell commented on Nov 9, 2022

    @kfcampbell
    Contributor

    I agree, this would be awesome to have! Do either of you have interest in opening a PR for this behavior?

  5. wwsean08 commented on Nov 10, 2022

    @wwsean08
    Contributor

    Looking into this, it looks like github.com/shurcooL/githubv4 will have to be updated first to support this new property unless I'm misinterpreting the code. I'm going to try and work on getting a PR against that repo this weekend to add the field. There are actually a couple of new fields missing which I'm going to try to get into the githubv4 library for branch protections. I'll post the PR link here if I'm able to get one opened over there since it's a pre-requisite for this work.

  6. wwsean08 commented on Nov 10, 2022

    @wwsean08
    Contributor

    Actually no need for me to open a PR, this one takes care of the necessary change, shurcooL/githubv4#107

  7. wwsean08 commented on Nov 16, 2022

    @wwsean08
    Contributor

    I've got a commit here that does all the work to add this option as well as the lock branch option since they were introduced at the same time. Because my test requires overriding the current version of the githubv4 library I haven't bothered opening a PR, but this should give someone a good start if someone else wants to take it up once the dependent change above is merged. I imagine you will be able to get away with leaving the go.mod at 1.16, but I had trouble which I think had to do with the go.mod (specifically golang.org/x/oauth2 v0.1.0) in the githubv4 repo which seemed to need a package introduced in 1.17, but I didn't dig too deep into the issue, so your results may vary.

    If I'm able to open a PR once that (or another PR on githubv4 gets merged) I will, but I am not able to spend as much time on this as I would like so hopefully my code snippet above helps someone down the line. Below is the code I wrote to test and validate it so it should work along with a screenshot of the results:

    terraform {
      required_providers {
        github = {
          source  = "integrations/github"
          version = "~> 5.0"
        }
      }
    }
    
    provider "github" {
      owner = "REDACTED"
    }
    
    data "github_repository" "repo" {
      full_name = "REDACTED/REDACTED"
    }
    
    resource "github_branch_protection" "protection" {
      repository_id              = data.github_repository.repo.node_id
      pattern                    = "test"
      lock_branch                = true
      required_pull_request_reviews {
        require_last_push_approval = true
      }
    }
    

    Screen Shot 2022-11-16 at 3 36 50 PM

  8. wwsean08 commented on Nov 27, 2022

    @wwsean08
    Contributor

    Good news, today a PR I opened that just updates the schema got merged 🎉 . Friday I will look to open a simplified version of my previous change as a PR to hopefully get this feature implemented

  9. added and removed
    Status: Triage
    on Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Feature

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions