Skip to content

Allow force pushes - everyone

Problem to solve

Protected branches in GitLab are implemented differently than in GitHub. For example, in GitHub there are some protected rules that you can apply on one or a few branches that match an expression, while those rules exist in GitLab as a general project settings for all branches. In this issue we make the mapping, so if a protected rule is defined in GH, and similar rule exists in GitLab general settings, we will configure the migrated GitLab project with this rule as a general settings, and this rule will be applied to all branches.

Purposed solution

GitHub's "Settings" > "Branches" > "Allow force pushes" > "Everyone" should be mapped into GitLab's "Settings" > "Repository" > "Protected branches" > "Allowed to force push".

If on GitHub this setting is set as not "Everyone" but "Specify who" then we should ignore it because GitLab doesn't support this level of configuration yet.

It's safer to add less permissions (which we do here), but in this case we need make sure the user is aware of this differences by stressing this in documentation.

 Scenario: "Allow force pushes" - "everyone" 
    Given "Allow force pushes" is defined in GitHub repository as a branch protected rule, and "Everyone" is selected
    When a user imports this repository to GitLab
    Then "Allowed to force push" will be check on in GitLab protected branches settings

Technical details

Get branch protection rules from Github API. Look at allow_force_pushes and put it's value into project.protected_branches allow_force_push attribute.

Note: previously we decided to use the strictest set of branch protection rules (in this issue). So, if the imported protected branch is also protected in GitLab, we will apply the strictest rule for the allow_force_push attribute.

Edited by Tetiana Zavediuk