Skip to content

Map 'Require pull request before merging' GitHub rule with access_levels

What does this MR do and why?

It solves Require a pull request before merging

Screenshots or screen recordings

map-require-pr-before-merging-with-access_levels

How to set up and validate locally

Scenario 1:

  1. On GitHub create a protection rule with "Require a pull request before merging" enabled for any branch
  2. Import the project from GitHub to GitLab
  3. Go to project -> Settings -> Repository -> expand Protected branches section
  4. Ensure the same branch is protected on GitLab with such setting:
  • Allowed to push - No one

Protected branch is the default branch:


Scenario 2:

  1. On GitLab go to Admin Area -> Settings -> Repository -> Default branch -> enable Partially protected -> Save changes
  2. On GitHub create a protection rule with any enabled options except "Require a pull request before merging" for default branch
  3. Import the project from GitHub to GitLab
  4. Go to project -> Settings -> Repository -> expand Protected branches section
  5. Ensure the default branch is protected with such setting:
  • Allowed to push - Developers + Maintainers
  • Allowed to merge - Maintainers

Scenario 3:

  1. On GitLab go to Admin Area -> Settings -> Repository -> Default branch -> enable any option (e.g. Protected against pushes) except Partially protected -> Save changes 2-4. the same as in Scenario 2
  2. Ensure the default branch is protected with such setting:
  • Allowed to push - Maintainers
  • Allowed to merge - Developers + Maintainers (if in p.1 Protected against pushes was chosen) or Maintainers (if in p.1 Not protected or Fully protected was chosen)

Protected branch is also protected on GitLab: (scenarios 4-7 cannot be validated until Group-level protected branches MVC is implemented)


Scenario 4:

  1. On GitHub create a protection rule with any enabled options except "Require a pull request before merging" for non-default branch (e.g. staging)
  2. On GitLab go to some group's Settings -> Repository -> Protected branches -> create protected rule for the staging branch with such setting: Allowed to push - No one (or Developers + Maintainers, or Maintainers)
  3. Import the project from GitHub to GitLab to the group from p.2
  4. Go to project -> Settings -> Repository -> expand Protected branches section
  5. Ensure the staging branch is protected with such setting:
  • Allowed to push - No one (or Developers + Maintainers, or Maintainers) (the same as in p.2)

Scenario 5:

  1. the same as in Scenario 4
  2. On GitLab go to some group's Settings -> Repository -> Protected branches -> create protected rule for the staging branch with such setting: Allowed to push - choose any user
  3. the same as in Scenario 4
  4. the same as in Scenario 4
  5. Ensure the staging branch is protected with such setting:
  • Allowed to push - Maintainers

Scenario 6:

  1. the same as in Scenario 4
  2. On GitLab go to some group's Settings -> Repository -> Protected branches -> create protected rule for the staging branch with such setting: Allowed to merge - No one
  3. the same as in Scenario 4
  4. the same as in Scenario 4
  5. Ensure the staging branch is protected with such setting:
  • Allowed to merge - No one

Scenario 7:

  1. the same as in Scenario 4
  2. On GitLab go to some group's Settings -> Repository -> Protected branches -> create protected rule for the staging branch with such setting: Allowed to merge - Developers + Maintainers (or Maintainers)
  3. the same as in Scenario 4
  4. the same as in Scenario 4
  5. Ensure the staging branch is protected with such setting:
  • Allowed to merge - Developers + Maintainers (or Maintainers) (the same as in p.2)

Protected branch is neither default nor protected on GitLab:


Scenario 8:

  1. On GitHub create a protection rule with any enabled options except "Require a pull request before merging" for non-default branch (e.g. staging)
  2. Import the project from GitHub to GitLab
  3. Go to project -> Settings -> Repository -> expand Protected branches section
  4. Ensure the staging branch is protected with such settings:
  • Allowed to push - Maintainers
  • Allowed to merge - Maintainers

MR acceptance checklist

Edited by Tetiana Zavediuk

Merge request reports

Loading