Skip to content

Preserve branch protection status during GitHub import

Rostyslav Safonov requested to merge rs-epic-22650-github-import-branches into master

What does this MR do and why?

Preserve branch protection status when importing from GitHub. When a one imports a repo from GitHub, its master branch automatically gets protection, even if on GitHub it was not protected. It causes some problems. For example if I like to rewrite history now I have to walk all there repos and unprotect their master branches.

As the solution for this issue in this PR I added mechanism that checks which branches are protected and pulls protection details for each of them. For each branch that is protected it will create separated rule. Unfortunately github doesn't give us API to grep the protection rules of the repository itself.

Note: we only apply GitHub's protection rules to branch if they are stricter than GitLab's rules. So if protection rules are not configured in GitLab, or are less strict than GH rules, we use GH rules.

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Merge request reports