Mirroring works incorrectly in pull mode

Summary

Mirroring in pull mode ignores "Only mirror protected branches" and copies all the branches available.

Steps to reproduce

  1. create new project
  2. open mirroring settings
  3. setup https based origin with authentication by password
  4. click "Only mirror protected branches"
  5. wait for replication
  6. see all the branches
  7. see default and protected branches assigned to random branch

Gitlab version

GitLab Enterprise Edition 12.0.0-ee

What is the expected correct behavior?

  1. default should go to master or historically earliest
  2. replication should respect "only protected" setting and replicate protection flag

Possible fixes

  1. Do first replication
  2. Clean up not needed branches
  3. Reassign default and protected flags
  4. Subsequent replications work as expected