Always pass full refs to Project#protected_for?

We should completely replace passing ref names to Project#protected_for? with using full refs.

https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2596 prevents ambiguity in the protected_for? by supporting both full refs and ref names and erroring out on ambiguous refs.

To better abstract the concepts of full ref and ref name we should create classes for them (Gitlab::Git::FullRef and Giltab::Git::RefName).

This method gets called from Gitlab::Ci::Pipeline::Chain::Command, which gets built in CreatePipelineService which receives parameters from the controller which receives parameters from the fronted. All of those places send back just the ref name. Fixing this requires those parts of the frontend to be reworked into sending back full refs. There's also lots of places in specs where we use only ref names.

All other occurrences of protected_for? are covered in https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2596 and use full refs as a parameter.

I see a couple of steps for achieving this:

  1. Prevent ambiguity (https://dev.gitlab.org/gitlab/gitlabhq/merge_requests/2596)
  2. Use only full refs when calling Projected#protected_for? - requires frontend refactor (https://gitlab.com/gitlab-org/gitlab-ce/issues/54700)
  3. Simplify Project#protected_for? and remove parts of code which are no longer necessary (https://gitlab.com/gitlab-org/gitlab-ce/issues/54701)
  4. Use a class based approach for handling refs (https://gitlab.com/gitlab-org/gitlab-ce/issues/54702)
Edited by Matija Čupić