Use dedicated methods for counting branches and tags
This started out as "Lets add two methods to count and cache some data" and ended up in a clean-up/fix of some existing code. The two problems were:
- Different code was used for adding/removing branches/tags via Git and the UI
- The code used for the UI didn't have any RSpec tests, and I couldn't find any Spinach tests either (though grepping for Spinach stuff is hard)
This MR addresses the following:
-
Repository#branch_count
andRepository#tag_count
are used to count and cache the number of branches/tags, these methods are then used on the branches/commits/tags pages. -
Repository#add_tag
,Repository#add_branch
,Repository#rm_tag
andRepository#rm_branch
now all the appropriate before/after hook methods instead of calling a random single cache expiration method. This ensures caches are properly flushed when adding/removing tags/branches via the UI. - RSpec tests were added for the above methods.
This fixes gitlab-org/gitlab-ce#13459